Skip to content

Instantly share code, notes, and snippets.

@ripter
Created January 18, 2018 18:44
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 ripter/49c7985f0b99b6c04c27f680b89bb380 to your computer and use it in GitHub Desktop.
Save ripter/49c7985f0b99b6c04c27f680b89bb380 to your computer and use it in GitHub Desktop.
getQueryParams as an Object
function getQueryParams() {
let match, result = {}, reg = /[&?]([^=]+)=([^&]+)/g;
// Match each reg in the queryString (aka search) and add it to the result object.
while (match = reg.exec(location.search)) { result[match[1]] = match[2]; }
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment