-
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 <targos@protonmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
- 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(), ''); | ||
} |