Last active
August 20, 2016 13:50
-
-
Save xwartz/12678ec6278e4ff9e0bf892d9db2186f to your computer and use it in GitHub Desktop.
get query string from url
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
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