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

array holes incorrectly copied into object on large index #5

Closed
dougwilson opened this issue Aug 6, 2014 · 4 comments
Closed

array holes incorrectly copied into object on large index #5

dougwilson opened this issue Aug 6, 2014 · 4 comments
Assignees
Labels
Milestone

Comments

@dougwilson
Copy link
Contributor

The following:

qs.parse('a[2]=2&a[999999999]=1')

results in the following

{ a: { '0': undefined, '1': undefined, '2': '2', '999999999': '1' } }

Since 0 and 1 were actually holes in the array (i.e. !(0 in arr)), they should not have properties created from them in the object. I would expect:

{ a: { '2': '2', '999999999': '1' } }

which is the output if you had them backwards: qs.parse('a[999999999]=1&a[2]=2')

TL;DR I think qs.parse('a[2]=2&a[999999999]=1') should have the same resulting object (with the same existing properties) as qs.parse('a[999999999]=1&a[2]=2').

@nlf
Copy link
Collaborator

nlf commented Aug 6, 2014

Ah, good catch. Thanks for reporting it. I'll get it taken care of

@dougwilson
Copy link
Contributor Author

@nlf by the way, you guys are awesome :)

@nlf
Copy link
Collaborator

nlf commented Aug 6, 2014

Closed via f93ff35

@nlf nlf closed this as completed Aug 6, 2014
@nlf
Copy link
Collaborator

nlf commented Aug 6, 2014

Just published it as v1.0.2, thanks @dougwilson!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants