Skip to content

url: fix URLSearchParams(null) per spec#63782

Open
marcopiraccini wants to merge 1 commit into
nodejs:mainfrom
marcopiraccini:url-searchparams-null
Open

url: fix URLSearchParams(null) per spec#63782
marcopiraccini wants to merge 1 commit into
nodejs:mainfrom
marcopiraccini:url-searchparams-null

Conversation

@marcopiraccini
Copy link
Copy Markdown
Contributor

@marcopiraccini marcopiraccini commented Jun 7, 2026

url: fix URLSearchParams(null) to produce "null=" per spec

Per the WHATWG URL spec, the URLSearchParams constructor accepts a (sequence<sequence<USVString>> or record<USVString, USVString> or USVString) union. null is not a sequence or record, so WebIDL union resolution falls through to USVString, where ToString(null) is "null".

Here we short-circuited on init == null, treating null the same as undefined and producing an empty string.

Before:

new URLSearchParams(null).toString() // ''

After (matches Chrome and Deno):

new URLSearchParams(null).toString() // 'null='

Fixes: #63559

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/url

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Jun 7, 2026
Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
@marcopiraccini marcopiraccini force-pushed the url-searchparams-null branch from 12a1e52 to 2919266 Compare June 7, 2026 06:39
@marcopiraccini marcopiraccini marked this pull request as ready for review June 7, 2026 06:40
@marcopiraccini marcopiraccini changed the title url: fix URLSearchParams(null) to prudce null= per spec url: fix URLSearchParams(null) per spec Jun 7, 2026
Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 7, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 7, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@gurgunday gurgunday added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 7, 2026
@mcollina mcollina added the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: URLSearchParams(null) behavior deviates from WHATWG standard / browsers

6 participants