2022-04-05 15:58:12 -04:00
|
|
|
export const getWindowLocationSearch = (win?: Window | null | undefined) => {
|
2022-04-05 15:15:54 -04:00
|
|
|
let search = (win || window).location.search;
|
|
|
|
|
|
|
|
if (!search) {
|
|
|
|
const index = window.location.href.indexOf('?');
|
|
|
|
|
|
|
|
if (index != -1) {
|
|
|
|
search = window.location.href.substring(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return search || '';
|
|
|
|
};
|
2022-04-05 15:58:12 -04:00
|
|
|
|
|
|
|
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, ' '));
|
|
|
|
};
|