mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Remove getParameterByName global
This commit is contained in:
parent
8e66ba315a
commit
67169e2a6a
12 changed files with 23 additions and 15 deletions
|
@ -1,4 +1,4 @@
|
|||
export const getWindowLocationSearch = (win: Window | null | undefined) => {
|
||||
export const getWindowLocationSearch = (win?: Window | null | undefined) => {
|
||||
let search = (win || window).location.search;
|
||||
|
||||
if (!search) {
|
||||
|
@ -11,3 +11,16 @@ export const getWindowLocationSearch = (win: Window | null | undefined) => {
|
|||
|
||||
return search || '';
|
||||
};
|
||||
|
||||
export const getParameterByName = (name: string, url?: string | null | undefined) => {
|
||||
name = name.replace(/[[]/, '\\[').replace(/[\]]/, '\\]');
|
||||
const regexS = '[\\?&]' + name + '=([^&#]*)';
|
||||
const regex = new RegExp(regexS, 'i');
|
||||
const results = regex.exec(url || getWindowLocationSearch());
|
||||
|
||||
if (results == null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return decodeURIComponent(results[1].replace(/\+/g, ' '));
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue