mirror of
https://github.com/bitwarden/browser.git
synced 2024-10-09 05:57:40 +02:00
16 lines
391 B
TypeScript
16 lines
391 B
TypeScript
|
export function getQsParam(name: string) {
|
||
|
const url = window.location.href;
|
||
|
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, ' '));
|
||
|
}
|