Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

empty array inconsistencies with Node.js >= 0.11.14 #15

Closed
clayzermk1 opened this issue Jul 15, 2016 · 1 comment
Closed

empty array inconsistencies with Node.js >= 0.11.14 #15

clayzermk1 opened this issue Jul 15, 2016 · 1 comment

Comments

@clayzermk1
Copy link

What happens?

When I stringify an object with an empty array, I get a repeated & in the query string output.

querystring.stringify({null: null, undefined: undefined, emptyString: '', emptyArray: [], emptyObject: {}});
// 'null=&undefined=&emptyString=&&emptyObject='

What did you expect to happen?

I expected there to not be an extra & in the query string output since it has been patched in Node.js (nodejs/node-v0.x-archive@61ddad1, see nodejs/node-v0.x-archive#7971). Note that in Node.js 0.10, the behavior is consistent.

Thank you for your work and your time, cheers!

@medikoo
Copy link
Collaborator

medikoo commented Apr 11, 2017

Should be addressed with new versions as explained at #20 (PR's are welcome)

lennym added a commit to lennym/querystring that referenced this issue Sep 14, 2017
…ozala#15)

Previously `stringify` was encoding empty arrays inconsistently with node's `querytring` module.

For example `stringify({ foo:'', bar:[], baz: '' }) => 'foo=&&baz='` - note the extra `&`.

By adding a `filter` call to the fragments of the querystring before `join`-ing then these empty strings are removed, and the query string is encoded correctly.

Fixes Gozala#15
@Gozala Gozala closed this as completed in #24 Feb 8, 2018
Gozala added a commit that referenced this issue Feb 8, 2018
Fix issue (#15) with empty arrays not stringify-ing consistently with node
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

No branches or pull requests

2 participants