Skip to content

url: fix URLSearchParams(null) per spec - #63782

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
marcopiraccini:url-searchparams-null
Jun 9, 2026
Merged

url: fix URLSearchParams(null) per spec#63782
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
marcopiraccini:url-searchparams-null

Conversation

@marcopiraccini

@marcopiraccinimarcopiraccini commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

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:

newURLSearchParams(null).toString()// ''

After (matches Chrome and Deno):

newURLSearchParams(null).toString()// 'null='

Fixes: #63559

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/url

@nodejs-github-botnodejs-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 marked this pull request as ready for review June 7, 2026 06:40
@marcopiraccinimarcopiraccini changed the title url: fix URLSearchParams(null) to prudce null= per specurl: fix URLSearchParams(null) per specJun 7, 2026

@mcollinamcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@mcollinamcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 7, 2026
@github-actionsgithub-actionsBot 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

@gurgundaygurgunday added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 7, 2026
@mcollinamcollina added the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 7, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 9, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 62d143a into nodejs:mainJun 9, 2026
96 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 62d143a

aduh95 pushed a commit that referenced this pull request Jun 18, 2026
Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
PR-URL: #63782Fixes: #63559
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
aduh95 pushed a commit that referenced this pull request Jun 25, 2026
Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
PR-URL: #63782Fixes: #63559
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
aduh95 pushed a commit that referenced this pull request Jul 30, 2026
Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
PR-URL: #63782Fixes: #63559
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.needs-ciPRs that need a full CI run.whatwg-urlIssues 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

8 participants

@marcopiraccini@nodejs-github-bot@mcollina@lpinca@watilde@Renegade334@atlowChemi@gurgunday