summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/querystring.js1
-rw-r--r--test/simple/test-querystring.js3
2 files changed, 4 insertions, 0 deletions
diff --git a/lib/querystring.js b/lib/querystring.js
index ba2b1cc9d..69ea00854 100644
--- a/lib/querystring.js
+++ b/lib/querystring.js
@@ -77,6 +77,7 @@ var chunks = /(?:(?:^|\.)([^\[\(\.]+)(?=\[|\.|$|\()|\[([^"'][^\]]*?)\]|\["([^\]"
// Parse a key=val string.
QueryString.parse = QueryString.decode = function (qs, sep, eq) {
var obj = {};
+ if (qs === undefined) { return {} }
String(qs).split(sep || "&").map(function (keyValue) {
var res = obj,
next,
diff --git a/test/simple/test-querystring.js b/test/simple/test-querystring.js
index e1598465f..0470b467f 100644
--- a/test/simple/test-querystring.js
+++ b/test/simple/test-querystring.js
@@ -165,3 +165,6 @@ var f = qs.stringify({
}, ";", ":")
}, ";", ":");
assert.equal(f, "a:b;q:x%3Ay%3By%3Az");
+
+
+assert.deepEqual({}, qs.parse());