Skip to content

Instantly share code, notes, and snippets.

@gregberns
Created January 24, 2018 17:08
Show Gist options
  • Save gregberns/8aea6899b2a63d2727560e08c0df0a83 to your computer and use it in GitHub Desktop.
Save gregberns/8aea6899b2a63d2727560e08c0df0a83 to your computer and use it in GitHub Desktop.
function parseQueryString(queryString) {
Array.prototype.fapply = function(fn) { return fn(this); };
return (queryString[0] === '?' ? queryString.substr(1) : '')
.split('&')
.fapply(i => (i.length && !i[0]) ? [] : i)
.map(i => i.length ? i.split('=') : [])
.reduce((a, i) => {
a[i[0]] = i[1];
return a;
}, {});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment