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

[fix] parsing a field that holds array of arrays #335

Merged
merged 1 commit into from Oct 6, 2019

Conversation

Om4ar
Copy link
Contributor

@Om4ar Om4ar commented Oct 4, 2019

fixes #327

lib/parse.js Outdated
@@ -87,6 +87,10 @@ var parseValues = function parseQueryStringValues(str, options) {
val = val.split(',');
}

if(part.indexOf('[]=') > -1){
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
if(part.indexOf('[]=') > -1){
if (part.indexOf('[]=') > -1) {

what happens with foo[][]=bar, or just []=a?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ljharb

foo[][]=bar will be parsed to { foo: ['bar'] }

[]=a will be parsed to { 0: 'a' }

my code doesn't affect these results, it will be the same result

lib/parse.js Outdated Show resolved Hide resolved
lib/parse.js Outdated Show resolved Hide resolved
lib/utils.js Outdated
@@ -1,7 +1,10 @@
'use strict';

var has = Object.prototype.hasOwnProperty;
var isArray = Array.isArray;
Copy link
Owner

Choose a reason for hiding this comment

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

whoops, turns out we already depended on this being available ¯\_(ツ)_/¯

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ljharb yes it is being used in stringify.js file too =D

Copy link
Contributor Author

@Om4ar Om4ar Oct 6, 2019

Choose a reason for hiding this comment

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

@ljharb
should i revert my changes on utils file and make another pr to replace Array.isArray with the polyfill across all the files ?

Copy link
Owner

Choose a reason for hiding this comment

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

nah for now just use Array.isArray the same way it's used in stringify.js.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, will revert my is changes for using this pollyfill

@ljharb ljharb merged commit f884e2d into ljharb:master Oct 6, 2019
ljharb pushed a commit that referenced this pull request Mar 24, 2020
ljharb pushed a commit that referenced this pull request Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

comma and bracket combined?
2 participants