Created
January 30, 2019 15:22
-
-
Save crates/9085af2aa1fd36cae09bb594b206fb08 to your computer and use it in GitHub Desktop.
Gets the current site's query string and returns it as a JavaScript object
This file contains 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
const getQueryStrAsObj = () => { | |
const paramsToObject = (keys) => { let result = {}; for(let entry of keys) result[entry[0]] = entry[1]; return result }; | |
const params = new URLSearchParams(location.search.substr(1, location.search.length - 1)); | |
return paramsToObject(params.entries()); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment