Skip to content

Instantly share code, notes, and snippets.

@amagee
Created June 29, 2017 00:34
Show Gist options
  • Select an option

  • Save amagee/c61327214d7b6cc14040585db12f596b to your computer and use it in GitHub Desktop.

Select an option

Save amagee/c61327214d7b6cc14040585db12f596b to your computer and use it in GitHub Desktop.
function parseQuery(qstr) {
var query = {};
var a = (qstr[0] === '?' ? qstr.substr(1) : qstr).split('&');
for (var i = 0; i < a.length; i++) {
var b = a[i].split('=');
query[decodeURIComponent(b[0])] = decodeURIComponent(b[1] || '');
}
return query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment