Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,9 @@ class URLSearchParams {
constructor(init = undefined) {
markTransferMode(this, false, false);

if (init == null) {
if (init === undefined) {
// Do nothing
} else if (typeof init === 'object' || typeof init === 'function') {
} else if (init !== null && (typeof init === 'object' || typeof init === 'function')) {
const method = init[SymbolIterator];
if (method === this[SymbolIterator] && #searchParams in init) {
// While the spec does not have this branch, we can use it as a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ function makeIterableFunc(array) {
let params;
params = new URLSearchParams(undefined);
assert.strictEqual(params.toString(), '');
// Per WebIDL union resolution, null is coerced to the USVString "null".
// Refs: https://url.spec.whatwg.org/#interface-urlsearchparams
params = new URLSearchParams(null);
assert.strictEqual(params.toString(), '');
assert.strictEqual(params.toString(), 'null=');
params = new URLSearchParams(false);
assert.strictEqual(params.toString(), 'false=');
params = new URLSearchParams(0);
assert.strictEqual(params.toString(), '0=');
params = new URLSearchParams(
makeIterableFunc([['key', 'val'], ['key2', 'val2']])
);
Expand Down
Loading