Skip to content

Instantly share code, notes, and snippets.

@dennishall1
Created January 3, 2017 20:23
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 dennishall1/bea527c2e981618709c50ae1c71243a7 to your computer and use it in GitHub Desktop.
Save dennishall1/bea527c2e981618709c50ae1c71243a7 to your computer and use it in GitHub Desktop.
// pass in either location.search or location.hash, taking care to remove the leading '?' or '#' first.
function getParams(str) {
return str.split("&").reduce(function(params, keyValuePair){
keyValuePair = keyValuePair.split('=');
params[decodeURIComponent(keyValuePair[0])] = decodeURIComponent(keyValuePair[1]);
return params;
}, {});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment