-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
url: align url format behavior with browsers
Fixes: #36887 PR-URL: #36903 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Daijiro Wachi <[email protected]>
- Loading branch information
Showing
2 changed files
with
21 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
|
||
{ | ||
const url = new (class extends URL { get hostname() { return 'bar.com'; } })('http://foo.com/'); | ||
assert.strictEqual(url.href, 'http://foo.com/'); | ||
assert.strictEqual(url.toString(), 'http://foo.com/'); | ||
assert.strictEqual(url.toJSON(), 'http://foo.com/'); | ||
assert.strictEqual(url.hash, ''); | ||
assert.strictEqual(url.host, 'foo.com'); | ||
assert.strictEqual(url.hostname, 'bar.com'); | ||
assert.strictEqual(url.origin, 'http://foo.com'); | ||
assert.strictEqual(url.password, ''); | ||
assert.strictEqual(url.protocol, 'http:'); | ||
assert.strictEqual(url.username, ''); | ||
assert.strictEqual(url.search, ''); | ||
assert.strictEqual(url.searchParams.toString(), ''); | ||
} |