url: always show password for URL instances

This matches browser behavior.

PR-URL: https://github.com/nodejs/node/pull/12420
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
Brian White 2017-04-15 00:42:25 -04:00 committed by James M Snell
parent e8f3163c75
commit d7ba2a6035
2 changed files with 2 additions and 5 deletions

View File

@ -206,8 +206,6 @@ class URL {
throw new errors.TypeError('ERR_INVALID_THIS', 'URL'); throw new errors.TypeError('ERR_INVALID_THIS', 'URL');
} }
const ctx = this[context];
if (typeof depth === 'number' && depth < 0) if (typeof depth === 'number' && depth < 0)
return opts.stylize('[Object]', 'special'); return opts.stylize('[Object]', 'special');
@ -221,8 +219,7 @@ class URL {
obj.origin = this.origin; obj.origin = this.origin;
obj.protocol = this.protocol; obj.protocol = this.protocol;
obj.username = this.username; obj.username = this.username;
obj.password = (opts.showHidden || ctx.password === '') ? obj.password = this.password;
this.password : '--------';
obj.host = this.host; obj.host = this.host;
obj.hostname = this.hostname; obj.hostname = this.hostname;
obj.port = this.port; obj.port = this.port;

View File

@ -21,7 +21,7 @@ assert.strictEqual(
origin: 'https://host.name:8080', origin: 'https://host.name:8080',
protocol: 'https:', protocol: 'https:',
username: 'username', username: 'username',
password: '--------', password: 'password',
host: 'host.name:8080', host: 'host.name:8080',
hostname: 'host.name', hostname: 'host.name',
port: '8080', port: '8080',