Skip to content

Commit e7b7d72

Browse files
watildeMylesBorins
authored andcommitted
test: cases to querystring related to empty string
+ Add cases to `qs.stringify` that return empty string + Add cases to `qs.parse` when `sep` or `eq` is empty PR-URL: #11329 Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 42304de commit e7b7d72

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/parallel/test-querystring.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,20 @@ assert.doesNotThrow(function() {
231231
assert.equal(f, 'a:b;q:x%3Ay%3By%3Az');
232232
}
233233

234+
// empty string
235+
assert.strictEqual(qs.stringify(), '');
236+
assert.strictEqual(qs.stringify(0), '');
237+
assert.strictEqual(qs.stringify([]), '');
238+
assert.strictEqual(qs.stringify(null), '');
239+
assert.strictEqual(qs.stringify(true), '');
240+
234241
check(qs.parse(), {});
235242

243+
// empty sep
244+
check(qs.parse('a', []), { a: '' });
245+
246+
// empty eq
247+
check(qs.parse('a', null, []), { '': 'a' });
236248

237249
// Test limiting
238250
assert.equal(

0 commit comments

Comments
 (0)