mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-18 11:28:23 -07:00
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
function getWindowLocationSearch(win) {
|
|
|
|
var search = (win || window).location.search;
|
|
|
|
if (!search) {
|
|
|
|
var index = window.location.href.indexOf('?');
|
|
if (index != -1) {
|
|
search = window.location.href.substring(index);
|
|
}
|
|
}
|
|
|
|
return search || '';
|
|
}
|
|
|
|
function getParameterByName(name, url) {
|
|
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
|
|
var regexS = "[\\?&]" + name + "=([^&#]*)";
|
|
var regex = new RegExp(regexS, "i");
|
|
|
|
var results = regex.exec(url || getWindowLocationSearch());
|
|
if (results == null)
|
|
return "";
|
|
else
|
|
return decodeURIComponent(results[1].replace(/\+/g, " "));
|
|
}
|
|
|
|
function replaceQueryString(url, param, value) {
|
|
var re = new RegExp("([?|&])" + param + "=.*?(&|$)", "i");
|
|
if (url.match(re))
|
|
return url.replace(re, '$1' + param + "=" + value + '$2');
|
|
else if (value) {
|
|
|
|
if (url.indexOf('?') == -1) {
|
|
return url + '?' + param + "=" + value;
|
|
}
|
|
|
|
return url + '&' + param + "=" + value;
|
|
}
|
|
|
|
return url;
|
|
} |