const getParameterByName = (name, url) => {
try {
if (!url)
url = window.location.href;
name = name.replace(/[[]]/g, "$&");
let regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex
.exec(url);
if (!results)
return null;
if (!results[2])
return ' ';
return decodeURIComponent(results[2].replace(/+/g, " "));
} catch (e) {
console.error("Err@ FN getParameterByName", e);
}
}
//routeId and soId are existing parameters
let routeId = getParameterByName("routeId");
let soId = getParameterByName("soId");
const timestamp = Date.now();
const plaintext = `${soId}-${routeId}-${timestamp}`;
// Base64 encode the plaintext
const passCode = window.btoa(plaintext)
const urlParams = new URLSearchParams(window.location.search);
urlParams.set('passCode', encodeURIComponent(passCode));
window.location.search = urlParams;