Skip to content

Instantly share code, notes, and snippets.

@fonzerelly
Created September 11, 2016 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fonzerelly/56622c961cfd7c0f5d3c1ff2147c08e0 to your computer and use it in GitHub Desktop.
Save fonzerelly/56622c961cfd7c0f5d3c1ff2147c08e0 to your computer and use it in GitHub Desktop.
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