mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
Move web to apps/web and bitwarden_license/bit-web
This commit is contained in:
30
apps/web/src/connectors/common.ts
Normal file
30
apps/web/src/connectors/common.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
export function getQsParam(name: string) {
|
||||
const url = window.location.href;
|
||||
// eslint-disable-next-line
|
||||
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, " "));
|
||||
}
|
||||
|
||||
export function b64Decode(str: string, spaceAsPlus = false) {
|
||||
if (spaceAsPlus) {
|
||||
str = str.replace(/ /g, "+");
|
||||
}
|
||||
|
||||
return decodeURIComponent(
|
||||
Array.prototype.map
|
||||
.call(atob(str), (c: string) => {
|
||||
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
|
||||
})
|
||||
.join("")
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user