Skip to content

Commit fe3e419

Browse files
cloudheadry
authored andcommitted
querystring.parse: handle undefined value properly
1 parent ffbbc46 commit fe3e419

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

lib/querystring.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ var chunks = /(?:(?:^|\.)([^\[\(\.]+)(?=\[|\.|$|\()|\[([^"'][^\]]*?)\]|\["([^\]"
7777
// Parse a key=val string.
7878
QueryString.parse = QueryString.decode = function (qs, sep, eq) {
7979
var obj = {};
80+
if (qs === undefined) { return {} }
8081
String(qs).split(sep || "&").map(function (keyValue) {
8182
var res = obj,
8283
next,

test/simple/test-querystring.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,6 @@ var f = qs.stringify({
165165
}, ";", ":")
166166
}, ";", ":");
167167
assert.equal(f, "a:b;q:x%3Ay%3By%3Az");
168+
169+
170+
assert.deepEqual({}, qs.parse());

0 commit comments

Comments
 (0)