Skip to content

Commit dd2e135

Browse files
watildejasnell
authored andcommitted
test: add two test cases for querystring
+ Check an empty substring: In `querystring`, if the `maxKeys` is 1 and the state machine finds an empty substring between separators, it should return an empty object. + Test invalid encoded strings: If provided string is an invalid encoded string in `query.parse`, it will not be encoded. PR-URL: #11481 Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 5da9524 commit dd2e135

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

test/parallel/test-querystring.js

+7
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,11 @@ assert.strictEqual(
288288
Object.keys(qs.parse('a=1&b=1&c=1', null, null, { maxKeys: 1 })).length,
289289
1);
290290

291+
// Test limiting with a case that starts from `&`
292+
assert.strictEqual(
293+
Object.keys(qs.parse('&a', null, null, { maxKeys: 1 })).length,
294+
0);
295+
291296
// Test removing limit
292297
function testUnlimitedKeys() {
293298
const query = {};
@@ -334,6 +339,8 @@ assert.strictEqual(qs.unescapeBuffer('a%20').toString(), 'a ');
334339
assert.strictEqual(qs.unescapeBuffer('a%2g').toString(), 'a%2g');
335340
assert.strictEqual(qs.unescapeBuffer('a%%').toString(), 'a%%');
336341

342+
// Test invalid encoded string
343+
check(qs.parse('%\u0100=%\u0101'), { '%Ā': '%ā' });
337344

338345
// Test custom decode
339346
function demoDecode(str) {

0 commit comments

Comments
 (0)