GeezerVison is showing github.com — url: align url format behavior with browsers · nodejs/node@d13fc6e
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/url.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -416,7 +416,7 @@ ObjectDefineProperties(URL.prototype, { |
416 | 416 | ret += '@'; |
417 | 417 | } |
418 | 418 | ret += options.unicode ? |
419 | | - domainToUnicode(this.hostname) : this.hostname; |
| 419 | + domainToUnicode(ctx.host) : ctx.host; |
420 | 420 | if (ctx.port !== null) |
421 | 421 | ret += `:${ctx.port}`; |
422 | 422 | } else if (ctx.scheme === 'file:') { |
|
Collapse file
Copy file name to clipboard +20Lines changed: 20 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +require('../common'); |
| 4 | +const assert = require('assert'); |
| 5 | + |
| 6 | +{ |
| 7 | + const url = new (class extends URL { get hostname() { return 'bar.com'; } })('http://foo.com/'); |
| 8 | + assert.strictEqual(url.href, 'http://foo.com/'); |
| 9 | + assert.strictEqual(url.toString(), 'http://foo.com/'); |
| 10 | + assert.strictEqual(url.toJSON(), 'http://foo.com/'); |
| 11 | + assert.strictEqual(url.hash, ''); |
| 12 | + assert.strictEqual(url.host, 'foo.com'); |
| 13 | + assert.strictEqual(url.hostname, 'bar.com'); |
| 14 | + assert.strictEqual(url.origin, 'http://foo.com'); |
| 15 | + assert.strictEqual(url.password, ''); |
| 16 | + assert.strictEqual(url.protocol, 'http:'); |
| 17 | + assert.strictEqual(url.username, ''); |
| 18 | + assert.strictEqual(url.search, ''); |
| 19 | + assert.strictEqual(url.searchParams.toString(), ''); |
| 20 | +} |