Skip to content

Instantly share code, notes, and snippets.

@zplume
Created November 2, 2017 10:55
Show Gist options
  • Save zplume/3be8201e95001721ed1bc58e3afec824 to your computer and use it in GitHub Desktop.
Save zplume/3be8201e95001721ed1bc58e3afec824 to your computer and use it in GitHub Desktop.
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