Skip to content

Commit 9c339b3

Browse files
committed
hasOwnProperty instead of falsey check, closes #37
1 parent 8a90b77 commit 9c339b3

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/parse.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internals.parseValues = function (str, options) {
2929
var key = Utils.decode(part.slice(0, pos));
3030
var val = Utils.decode(part.slice(pos + 1));
3131

32-
if (!obj[key]) {
32+
if (!obj.hasOwnProperty(key)) {
3333
obj[key] = val;
3434
}
3535
else {

test/parse.js

+1
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ describe('#parse', function () {
190190

191191
expect(Qs.parse('a[]=b&a[]=&a[]=c')).to.deep.equal({ a: ['b', '', 'c'] });
192192
expect(Qs.parse('a[0]=b&a[1]=&a[2]=c&a[19]=')).to.deep.equal({ a: ['b', '', 'c', ''] });
193+
expect(Qs.parse('a[]=&a[]=b&a[]=c')).to.deep.equal({ a: ['', 'b', 'c'] });
193194
done();
194195
});
195196

0 commit comments

Comments
 (0)