2021-03-16 17:44:31 +01:00
|
|
|
export function getQsParam(name: string) {
|
|
|
|
const url = window.location.href;
|
2022-02-24 12:10:07 +01:00
|
|
|
// eslint-disable-next-line
|
2021-03-16 17:44:31 +01:00
|
|
|
name = name.replace(/[\[\]]/g, "\\$&");
|
|
|
|
const regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)");
|
|
|
|
const results = regex.exec(url);
|
|
|
|
|
|
|
|
if (!results) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (!results[2]) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
|
|
|
}
|
2021-07-23 21:30:04 +02:00
|
|
|
|
|
|
|
export function b64Decode(str: string) {
|
|
|
|
return decodeURIComponent(
|
|
|
|
Array.prototype.map
|
|
|
|
.call(atob(str), (c: string) => {
|
|
|
|
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
|
|
|
|
})
|
|
|
|
.join("")
|
|
|
|
);
|
|
|
|
}
|