Skip to content

Commit

Permalink
[Fix] stringify: avoid a crash when a filter key is null
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Aug 22, 2024
1 parent aa1f0a8 commit 96f4d93
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ var stringify = function stringify(

for (var j = 0; j < objKeys.length; ++j) {
var key = objKeys[j];
var value = typeof key === 'object' && typeof key.value !== 'undefined'
var value = typeof key === 'object' && key && typeof key.value !== 'undefined'
? key.value
: obj[key];

Expand Down
2 changes: 1 addition & 1 deletion test/stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ test('stringifies empty keys', function (t) {

t.test('stringifies non-string keys', function (st) {
var actual = qs.stringify({ a: 'b', 'false': {} }, {
filter: ['a', false],
filter: ['a', false, null],
allowDots: true,
encodeDotInKeys: true
});
Expand Down

0 comments on commit 96f4d93

Please sign in to comment.