Skip to content

[Fix] stringify: apply formatter to encoded key under strictNullHandling#554

Merged
ljharb merged 1 commit into
ljharb:mainfrom
deepview-autofix:deepview/9ce1b20709
Apr 27, 2026
Merged

[Fix] stringify: apply formatter to encoded key under strictNullHandling#554
ljharb merged 1 commit into
ljharb:mainfrom
deepview-autofix:deepview/9ce1b20709

Conversation

@deepview-autofix

Copy link
Copy Markdown
Contributor

Previously the null branch returned the raw encoder(prefix, ...) output (or raw prefix) without running it through formatter. With format: 'RFC1738' this caused keys containing spaces to serialize as %20 in strict-null mode while the normal primitive path produced +, yielding inconsistent output for the same key.

…Handling`

Previously the null branch returned the raw `encoder(prefix, ...)` output
(or raw `prefix`) without running it through `formatter`.
With `format: 'RFC1738'` this caused keys containing spaces to serialize as
`%20` in strict-null mode while the normal primitive path produced `+`,
yielding inconsistent output for the same key.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: DeepView Autofix <276251120+deepview-autofix@users.noreply.github.com>
Co-Authored-By: Nikita Skovoroda <chalkerx@gmail.com>
Co-Authored-By: Jordan Harband <ljharb@gmail.com>
Signed-off-by: Nikita Skovoroda <chalkerx@gmail.com>

@ChALkeR ChALkeR left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Before the fix:

> require('qs').stringify({'a a':null,'a b':1},{format:'RFC1738',strictNullHandling:true})
'a%20a&a+b=1'

Had both %20 and +.

Comment thread lib/stringify.js Outdated
@ljharb ljharb force-pushed the deepview/9ce1b20709 branch from f04f3c4 to e3062f7 Compare April 27, 2026 15:14

@ljharb ljharb left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

added an extra assertion with the same input, with the opposite strictNullHandling option

@ljharb ljharb merged commit e3062f7 into ljharb:main Apr 27, 2026
415 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants