Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ function compact(obj) {

for (var i in obj) {
if (hasOwnProperty.call(obj, i)) {
ret.push(obj[i]);
// We need to compact the nesting array too
// See https://github.com/visionmedia/node-querystring/issues/104
ret.push(compact(obj[i]));
}
}

Expand Down
7 changes: 7 additions & 0 deletions test/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ describe('qs.parse()', function(){
expect(q['a'].length).to.eql(2);
expect(q).to.eql({ a: ['2', '1'] });
})

it('should not create big nesting arrays of null objects', function () {
var q = qs.parse('a[0][999999999]=1');
console.log(q.a[0]);
expect(q['a'].length).to.eql(1);
expect(q['a'][0]).to.eql(['1']);
})

it('should not be able to override prototypes', function(){
var obj = qs.parse('toString=bad&bad[toString]=bad&constructor=bad');
Expand Down