Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fb34d9c

Browse filesBrowse files
davidtaikochaItalo A. Casas
authored andcommitted
test: increase querystring coverage
PR-URL: #12163 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent d6e9cf7 commit fb34d9c
Copy full SHA for fb34d9c

File tree

Expand file treeCollapse file tree

2 files changed

+11
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-2
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-querystring-escape.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-querystring-escape.js
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ assert.deepStrictEqual(qs.escape('test'), 'test');
99
assert.deepStrictEqual(qs.escape({}), '%5Bobject%20Object%5D');
1010
assert.deepStrictEqual(qs.escape([5, 10]), '5%2C10');
1111
assert.deepStrictEqual(qs.escape('Ŋōđĕ'), '%C5%8A%C5%8D%C4%91%C4%95');
12+
assert.deepStrictEqual(qs.escape('testŊōđĕ'), 'test%C5%8A%C5%8D%C4%91%C4%95');
13+
assert.deepStrictEqual(qs.escape(`${String.fromCharCode(0xD800 + 1)}test`),
14+
'%F0%90%91%B4est');
15+
assert.throws(() => qs.escape(String.fromCharCode(0xD800 + 1)),
16+
/^URIError: URI malformed$/);
1217

1318
// using toString for objects
1419
assert.strictEqual(
@@ -17,9 +22,11 @@ assert.strictEqual(
1722
);
1823

1924
// toString is not callable, must throw an error
20-
assert.throws(() => qs.escape({toString: 5}));
25+
assert.throws(() => qs.escape({toString: 5}),
26+
/^TypeError: Cannot convert object to primitive value$/);
2127

2228
// should use valueOf instead of non-callable toString
2329
assert.strictEqual(qs.escape({toString: 5, valueOf: () => 'test'}), 'test');
2430

25-
assert.throws(() => qs.escape(Symbol('test')));
31+
assert.throws(() => qs.escape(Symbol('test')),
32+
/^TypeError: Cannot convert a Symbol value to a string$/);
Collapse file

‎test/parallel/test-querystring.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-querystring.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ function demoDecode(str) {
308308
}
309309
check(qs.parse('a=a&b=b&c=c', null, null, { decodeURIComponent: demoDecode }),
310310
{ aa: 'aa', bb: 'bb', cc: 'cc' });
311+
check(qs.parse('a=a&b=b&c=c', null, '==', { decodeURIComponent: (str) => str }),
312+
{ 'a=a': '', 'b=b': '', 'c=c': '' });
311313

312314
// Test QueryString.unescape
313315
function errDecode(str) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.