Created
September 11, 2016 20:02
-
-
Save fonzerelly/56622c961cfd7c0f5d3c1ff2147c08e0 to your computer and use it in GitHub Desktop.
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
function objectizeUrlSearch (paramString) { | |
var | |
pairStrings = paramString.split('&'), | |
pairs = [], | |
result = {}, | |
i; | |
for (i = 0; i < pairStrings.length; i++) { | |
pairs.push(pairStrings[i].split('=')); | |
} | |
for (i = 0; i < pairs.length; i++) { | |
var pair = pairs[i]; | |
if (result[key(pair)]) { | |
result[key(pair)] = [] | |
.concat(result[key(pair)]) | |
.concat(value(pair)); | |
} else { | |
result[key(pair)] = value(pair); | |
} | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment