Skip to content

Instantly share code, notes, and snippets.

@ranacseruet
Created February 22, 2017 15:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ranacseruet/34cc3296a43abf5afd5c2811ccfbdfd8 to your computer and use it in GitHub Desktop.
Save ranacseruet/34cc3296a43abf5afd5c2811ccfbdfd8 to your computer and use it in GitHub Desktop.
Parse url search queries into js object
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