Skip to content

Instantly share code, notes, and snippets.

@xwartz
Last active August 20, 2016 13:50
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 xwartz/12678ec6278e4ff9e0bf892d9db2186f to your computer and use it in GitHub Desktop.
Save xwartz/12678ec6278e4ff9e0bf892d9db2186f to your computer and use it in GitHub Desktop.
get query string from url
let getQueryString = (key, queryStr = location.search + location.hash) => {
let reg = new RegExp('(^|\\?|&)' + key + '=([^&]*)(\\s|&|$)', 'i')
return reg.test(queryStr) ? decodeURIComponent(RegExp.$2) : ''
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment