Skip to content

Instantly share code, notes, and snippets.

@noahduncan
Created November 28, 2016 23:25
Show Gist options
  • Save noahduncan/ed0b2d29bded55d1464f0521ad3e1b4b to your computer and use it in GitHub Desktop.
Save noahduncan/ed0b2d29bded55d1464f0521ad3e1b4b to your computer and use it in GitHub Desktop.
Get Query Params
function getQueryParams(qs) {
qs = qs.split('+').join(' ');
var params = {};
var tokens;
var re = /[?&]?([^=]+)=([^&]*)/g;
while (tokens = re.exec(qs)) {
params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
}
return params;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment