Created
June 6, 2018 11:30
-
-
Save allenfantasy/dc29a6d45ea33139e9a5c0f3f23db0ae to your computer and use it in GitHub Desktop.
getQueryStringObject
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 getQueryStringObject = url => { | |
let query = url.split('?') | |
if (query.length > 1) { | |
let params = query[1].split('&') | |
let values = {} | |
for (let i = 0; i < params.length; i++) { | |
let param = params[i].split('=') | |
values[param[0]] = param[1] | |
} | |
return values | |
} else { | |
return {} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment