Browse Source

test: add two test cases for querystring

+ Cover untested branch in the state machine with the string
  that its first letter is `+` in the key/value.
+ `qs.unescapeBuffer` shouldn't decode `+` to space.

PR-URL: https://github.com/nodejs/node/pull/11551
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
v6
Daijiro Wachi 8 years ago
committed by Anna Henningsen
parent
commit
acc3a80546
No known key found for this signature in database GPG Key ID: D8B9F5AEAE84E4CF
  1. 2
      test/parallel/test-querystring.js

2
test/parallel/test-querystring.js

@ -69,6 +69,7 @@ const qsTestCases = [
['a&a&a&a&', 'a=&a=&a=&a=', { a: [ '', '', '', '' ] }],
['a=&a=value&a=', 'a=&a=value&a=', { a: [ '', 'value', '' ] }],
['foo+bar=baz+quux', 'foo%20bar=baz%20quux', { 'foo bar': 'baz quux' }],
['+foo=+bar', '%20foo=%20bar', { ' foo': ' bar' }],
[null, '', {}],
[undefined, '', {}]
];
@ -333,6 +334,7 @@ assert.strictEqual(0xa2, b[18]);
assert.strictEqual(0xe6, b[19]);
assert.strictEqual(qs.unescapeBuffer('a+b', true).toString(), 'a b');
assert.strictEqual(qs.unescapeBuffer('a+b').toString(), 'a+b');
assert.strictEqual(qs.unescapeBuffer('a%').toString(), 'a%');
assert.strictEqual(qs.unescapeBuffer('a%2').toString(), 'a%2');
assert.strictEqual(qs.unescapeBuffer('a%20').toString(), 'a ');

Loading…
Cancel
Save