Skip to content

Commit e416967

Browse files
watildeitaloacasas
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 <hello@about-hiroppy.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 3bdac54 commit e416967

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/parallel/test-querystring.js

+12
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,20 @@ assert.doesNotThrow(function() {
224224
assert.strictEqual(f, 'a:b;q:x%3Ay%3By%3Az');
225225
}
226226

227+
// empty string
228+
assert.strictEqual(qs.stringify(), '');
229+
assert.strictEqual(qs.stringify(0), '');
230+
assert.strictEqual(qs.stringify([]), '');
231+
assert.strictEqual(qs.stringify(null), '');
232+
assert.strictEqual(qs.stringify(true), '');
233+
227234
check(qs.parse(), {});
228235

236+
// empty sep
237+
check(qs.parse('a', []), { a: '' });
238+
239+
// empty eq
240+
check(qs.parse('a', null, []), { '': 'a' });
229241

230242
// Test limiting
231243
assert.strictEqual(

0 commit comments

Comments
 (0)