Skip to content

fix: skip empty array values in stringify#91

Merged
anonrig merged 1 commit intoanonrig:mainfrom
deepview-autofix:deepview/47c1007edf
Apr 19, 2026
Merged

fix: skip empty array values in stringify#91
anonrig merged 1 commit intoanonrig:mainfrom
deepview-autofix:deepview/47c1007edf

Conversation

@deepview-autofix
Copy link
Copy Markdown
Contributor

Empty array values caused malformed query strings with leading or trailing & separators because the separator was appended unconditionally for every key while the inner loop produced no output. For example, stringify({a: [], b: "1"}) produced "&b=1" and stringify({a: "1", b: []}) produced "a=1&".

Skip empty arrays entirely and only emit the separator when the current key actually contributes a key=value pair, matching the behavior of the native querystring module.

Empty array values caused malformed query strings with leading or
trailing `&` separators because the separator was appended unconditionally
for every key while the inner loop produced no output. For example,
`stringify({a: [], b: "1"})` produced `"&b=1"` and
`stringify({a: "1", b: []})` produced `"a=1&"`.

Skip empty arrays entirely and only emit the separator when the current
key actually contributes a key=value pair, matching the behavior of the
native `querystring` module.

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>
Signed-off-by: Nikita Skovoroda <chalkerx@gmail.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.31%. Comparing base (9dcbaf2) to head (9d137ff).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #91      +/-   ##
==========================================
+ Coverage   68.97%   69.31%   +0.34%     
==========================================
  Files           7        7              
  Lines         448      453       +5     
  Branches       72       74       +2     
==========================================
+ Hits          309      314       +5     
  Misses        136      136              
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@anonrig
Copy link
Copy Markdown
Owner

anonrig commented Apr 17, 2026

How does node:query string behave?

@ChALkeR
Copy link
Copy Markdown
Contributor

ChALkeR commented Apr 17, 2026

@anonrig correctly.

> querystring.stringify({a:[],b:"1"})
'b=1'

@anonrig anonrig merged commit 1b1bbff into anonrig:main Apr 19, 2026
29 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