Created
February 22, 2017 15:03
-
-
Save ranacseruet/34cc3296a43abf5afd5c2811ccfbdfd8 to your computer and use it in GitHub Desktop.
Parse url search queries into js 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
static searchQueries() { | |
const queryString = window.location.search.substring(1) | |
const pairs = queryString.split('&') | |
let queryObj = {} | |
for (let i=0; i<pairs.length; i++) { | |
const keyVal = pairs[i].split('=') | |
queryObj[keyVal[0]] = decodeURIComponent(keyVal[1]) | |
} | |
return queryObj | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment