DigitalConsumer.FixMyGlass/src/helpers/querystring-helper.js
2025-01-27 18:06:01 -05:00

24 lines
860 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;
}