Skip to content

Instantly share code, notes, and snippets.

@wildeyes
Created July 22, 2018 14:37
Show Gist options
  • Save wildeyes/4b984b9f6ddb31c24b43b5e39de7534c to your computer and use it in GitHub Desktop.
Save wildeyes/4b984b9f6ddb31c24b43b5e39de7534c to your computer and use it in GitHub Desktop.
function parseQuery(queryString) {
var query = {};
var pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&');
for (var i = 0; i < pairs.length; i++) {
var pair = pairs[i].split('=');
query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');
}
return query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment