Created
November 2, 2017 10:55
-
-
Save zplume/3be8201e95001721ed1bc58e3afec824 to your computer and use it in GitHub Desktop.
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
function getQueryStringParam(searchKey) { | |
// get URI object | |
var uri = new URI(location.href); | |
// get query params | |
var queryParams = uri.getQueryAsObject(); | |
// get queryParam keys | |
var queryParamKeys = Object.keys(queryParams); | |
// get index of key, case insensitive | |
var keyIndex = queryParamKeys.map(key => key.toLowerCase()).indexOf(searchKey.toLowerCase()); | |
// handle key not found | |
if(keyIndex === -1) | |
return undefined; | |
// get actual key from queryParams | |
var key = queryParamKeys[keyIndex]; | |
// return value | |
return queryParams[key]; | |
} | |
var source = getQueryStringParam("source"); | |
window.location.href = source; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment