Created
January 18, 2018 18:44
-
-
Save ripter/49c7985f0b99b6c04c27f680b89bb380 to your computer and use it in GitHub Desktop.
getQueryParams as an Object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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