Skip to content

Commit 96f4d93

Browse files
committed
[Fix] stringify: avoid a crash when a filter key is null
1 parent aa1f0a8 commit 96f4d93

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/stringify.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ var stringify = function stringify(
162162

163163
for (var j = 0; j < objKeys.length; ++j) {
164164
var key = objKeys[j];
165-
var value = typeof key === 'object' && typeof key.value !== 'undefined'
165+
var value = typeof key === 'object' && key && typeof key.value !== 'undefined'
166166
? key.value
167167
: obj[key];
168168

test/stringify.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ test('stringifies empty keys', function (t) {
12981298

12991299
t.test('stringifies non-string keys', function (st) {
13001300
var actual = qs.stringify({ a: 'b', 'false': {} }, {
1301-
filter: ['a', false],
1301+
filter: ['a', false, null],
13021302
allowDots: true,
13031303
encodeDotInKeys: true
13041304
});

0 commit comments

Comments
 (0)