Created
January 11, 2011 21:42
-
-
Save bitdrift/775210 to your computer and use it in GitHub Desktop.
Node.js patch to fix query string parser to allow irregular nesting of parameters within namespace hierarchies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 78dfd4b323c43760d7587512ab3351c52232967e Mon Sep 17 00:00:00 2001 | |
From: Ryan Probasco <ryan@bitdrift.org> | |
Date: Tue, 11 Jan 2011 14:40:12 -0700 | |
Subject: [PATCH] Fix query string parser to allow irregular nesting of parameters within namespace hierarchies | |
--- | |
lib/querystring.js | 5 +++++ | |
1 files changed, 5 insertions(+), 0 deletions(-) | |
diff --git a/lib/querystring.js b/lib/querystring.js | |
index 69ea008..8019ef3 100644 | |
--- a/lib/querystring.js | |
+++ b/lib/querystring.js | |
@@ -95,6 +95,11 @@ QueryString.parse = QueryString.decode = function (qs, sep, eq) { | |
if (name in res) { | |
if (isArray || end) { | |
res = (res[name] = [res[name], next])[1]; | |
+ } else if (typeof(res[name]) === typeof("")) { | |
+ // handle query strings of form: foo=hello&foo.bar=goodbye | |
+ // becomes: {foo:{__str__:'hello',bar:'goodbye'}} | |
+ res[name] = {__str__:res[name]}; | |
+ res = res[name]; | |
} else { | |
res = res[name]; | |
} | |
-- | |
1.7.0.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment