mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
get api libs from bower
This commit is contained in:
parent
def418714f
commit
f36e664503
97 changed files with 16860 additions and 197 deletions
77
dashboard-ui/bower_components/hls.js/src/utils/url.js
vendored
Normal file
77
dashboard-ui/bower_components/hls.js/src/utils/url.js
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
var URLHelper = {
|
||||
|
||||
// build an absolute URL from a relative one using the provided baseURL
|
||||
// if relativeURL is an absolute URL it will be returned as is.
|
||||
buildAbsoluteURL: function(baseURL, relativeURL) {
|
||||
// remove any remaining space and CRLF
|
||||
relativeURL = relativeURL.trim();
|
||||
if (/^[a-z]+:/i.test(relativeURL)) {
|
||||
// complete url, not relative
|
||||
return relativeURL;
|
||||
}
|
||||
|
||||
var relativeURLQuery = null;
|
||||
var relativeURLHash = null;
|
||||
|
||||
var relativeURLHashSplit = /^([^#]*)(.*)$/.exec(relativeURL);
|
||||
if (relativeURLHashSplit) {
|
||||
relativeURLHash = relativeURLHashSplit[2];
|
||||
relativeURL = relativeURLHashSplit[1];
|
||||
}
|
||||
var relativeURLQuerySplit = /^([^\?]*)(.*)$/.exec(relativeURL);
|
||||
if (relativeURLQuerySplit) {
|
||||
relativeURLQuery = relativeURLQuerySplit[2];
|
||||
relativeURL = relativeURLQuerySplit[1];
|
||||
}
|
||||
|
||||
var baseURLHashSplit = /^([^#]*)(.*)$/.exec(baseURL);
|
||||
if (baseURLHashSplit) {
|
||||
baseURL = baseURLHashSplit[1];
|
||||
}
|
||||
var baseURLQuerySplit = /^([^\?]*)(.*)$/.exec(baseURL);
|
||||
if (baseURLQuerySplit) {
|
||||
baseURL = baseURLQuerySplit[1];
|
||||
}
|
||||
|
||||
var baseURLDomainSplit = /^((([a-z]+):)?\/\/[a-z0-9\.-]+(:[0-9]+)?\/)(.*)$/i.exec(baseURL);
|
||||
var baseURLProtocol = baseURLDomainSplit[3];
|
||||
var baseURLDomain = baseURLDomainSplit[1];
|
||||
var baseURLPath = baseURLDomainSplit[5];
|
||||
|
||||
var builtURL = null;
|
||||
if (/^\/\//.test(relativeURL)) {
|
||||
builtURL = baseURLProtocol+'://'+URLHelper.buildAbsolutePath('', relativeURL.substring(2));
|
||||
}
|
||||
else if (/^\//.test(relativeURL)) {
|
||||
builtURL = baseURLDomain+URLHelper.buildAbsolutePath('', relativeURL.substring(1));
|
||||
}
|
||||
else {
|
||||
var newPath = URLHelper.buildAbsolutePath(baseURLPath, relativeURL);
|
||||
builtURL = baseURLDomain + newPath;
|
||||
}
|
||||
|
||||
// put the query and hash parts back
|
||||
if (relativeURLQuery) {
|
||||
builtURL += relativeURLQuery;
|
||||
}
|
||||
if (relativeURLHash) {
|
||||
builtURL += relativeURLHash;
|
||||
}
|
||||
return builtURL;
|
||||
},
|
||||
|
||||
// build an absolute path using the provided basePath
|
||||
// adapted from https://developer.mozilla.org/en-US/docs/Web/API/document/cookie#Using_relative_URLs_in_the_path_parameter
|
||||
// this does not handle the case where relativePath is "/" or "//". These cases should be handled outside this.
|
||||
buildAbsolutePath: function(basePath, relativePath) {
|
||||
var sRelPath = relativePath;
|
||||
var nUpLn, sDir = '', sPath = basePath.replace(/[^\/]*$/, sRelPath.replace(/(\/|^)(?:\.?\/+)+/g, '$1'));
|
||||
for (var nEnd, nStart = 0; nEnd = sPath.indexOf('/../', nStart), nEnd > -1; nStart = nEnd + nUpLn) {
|
||||
nUpLn = /^\/(?:\.\.\/)*/.exec(sPath.slice(nEnd))[0].length;
|
||||
sDir = (sDir + sPath.substring(nStart, nEnd)).replace(new RegExp('(?:\\\/+[^\\\/]*){0,' + ((nUpLn - 1) / 3) + '}$'), '/');
|
||||
}
|
||||
return sDir + sPath.substr(nStart);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = URLHelper;
|
Loading…
Add table
Add a link
Reference in a new issue