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

Incorrect handling of arrays #70

Conversation

abdulrahmancz
Copy link

Add square brackets for array items of stringified query string. Remove square brackets while parsing query string with array items. Updated tests and readme. Also related ti issue#66.

Said Abdulrahman added 2 commits June 27, 2016 14:46
…ve square brackets while parsing query string with array items. Updated tests and readme.
@aweary
Copy link
Contributor

aweary commented Jun 27, 2016

This is inconsistent with how the native querystring module works in Node.

> querystring.stringify({ foo: ['bar', 'baz'] })
'foo=bar&foo=baz'

If the official specification doesn't clarify this behavior then it seems most reasonable to remain consistent with the platform.

@kevva
Copy link
Contributor

kevva commented Sep 6, 2016

This should definitely be behind a option like it is in https://github.com/ljharb/qs. We'd still want the current behaviour as default.

@@ -80,11 +81,12 @@ exports.stringify = function (obj, opts) {
if (val2 === undefined) {
return;
}
var arrayKey = encode(key, encode) + '[]';
Copy link
Contributor

Choose a reason for hiding this comment

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

Add an empty line before this.

@sindresorhus
Copy link
Owner

Closing for lack of response.

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.

4 participants