-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
url: set toStringTag for the URL class
PR-URL: #10562 Fixes: #10554 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
- Loading branch information
Showing
2 changed files
with
29 additions
and
14 deletions.
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,21 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const URL = require('url').URL; | ||
const toString = Object.prototype.toString; | ||
|
||
const url = new URL('http://example.org'); | ||
const sp = url.searchParams; | ||
|
||
const test = [ | ||
[toString.call(url), 'URL'], | ||
[toString.call(Object.getPrototypeOf(url)), 'URLPrototype'], | ||
[toString.call(sp), 'URLSearchParams'], | ||
[toString.call(Object.getPrototypeOf(sp)), 'URLSearchParamsPrototype'] | ||
]; | ||
|
||
test.forEach((row) => { | ||
assert.strictEqual(row[0], `[object ${row[1]}]`, | ||
`${row[0]} !== [object ${row[1]}]`); | ||
}); |