DigitalConsumer.FixMyGlass/src/helpers/querystring-helper.js
CarlNation ccc3feb15e CASH-160
CASH-160 promo code lost coming from content site /cjrepair.  Added all passed querystring keys to the redirect to return-user so they're not lost.
2025-01-24 13:50:40 -05:00

24 lines
No EOL
861 B
JavaScript

export function getQuerystringParameter(key) {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const lowerCaseParams = new URLSearchParams();
for (const [name, value] of urlParams) {
lowerCaseParams.append(name.toLowerCase(), value);
}
return lowerCaseParams.get(key) ? lowerCaseParams.get(key) : null;
}
// if you add the fmgPage to the querystringobject before calling, then pass true for skipFmgPageName
export function buildQuerystringObject(qso, skipFmgPageName=false) {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
for (const [name, value] of urlParams) {
if (name.toLowerCase() === "fmgpage" && skipFmgPageName) {
continue;
}
qso[name] = value;
}
return qso;
}