This commit is contained in:
Adam Bradley
2015-06-24 10:28:12 -05:00
parent e5caeb9b8f
commit 535dbf990f
8 changed files with 616 additions and 160 deletions

View File

@ -134,20 +134,22 @@ export const array = {
* Grab the query string param value for the given key.
* @param key the key to look for
*/
export function getQuerystring(key) {
export function getQuerystring(url, key) {
var queryParams = {};
const startIndex = window.location.href.indexOf('?');
if (startIndex !== -1) {
const queries = window.location.href.slice(startIndex + 1).split('&');
if (queries.length) {
queries.forEach((param) => {
var split = param.split('=');
queryParams[split[0]] = split[1];
});
if (url) {
const startIndex = url.indexOf('?');
if (startIndex !== -1) {
const queries = url.slice(startIndex + 1).split('&');
if (queries.length) {
queries.forEach((param) => {
var split = param.split('=');
queryParams[split[0]] = split[1];
});
}
}
if (key) {
return queryParams[key] || '';
}
}
if (key) {
return queryParams[key] || '';
}
return queryParams;
}