OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
API
/
swagger-ui-5.17.14
/
src
/
core
/
utils
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/07/2024 04:34:11 AM
rwxr-xr-x
📄
create-html-ready-id.js
444 bytes
08/07/2024 04:33:55 AM
rw-r--r--
📄
get-parameter-schema.js
2.3 KB
08/07/2024 04:33:55 AM
rw-r--r--
📄
index.js
22.91 KB
08/07/2024 04:33:55 AM
rw-r--r--
📄
jsonParse.js
415 bytes
08/07/2024 04:33:55 AM
rw-r--r--
📄
memoizeN.js
1.18 KB
08/07/2024 04:33:55 AM
rw-r--r--
📄
url.js
1.13 KB
08/07/2024 04:33:55 AM
rw-r--r--
Editing: url.js
Close
export function isAbsoluteUrl(url) { return url.match(/^(?:[a-z]+:)?\/\//i) // Matches http://, HTTP://, https://, ftp://, //example.com, } export function addProtocol(url) { if (!url.match(/^\/\//i)) return url // Checks if protocol is missing e.g. //example.com return `${window.location.protocol}${url}` } export function buildBaseUrl(selectedServer, specUrl) { if (!selectedServer) return specUrl if (isAbsoluteUrl(selectedServer)) return addProtocol(selectedServer) return new URL(selectedServer, specUrl).href } export function buildUrl(url, specUrl, { selectedServer="" } = {}) { if (!url) return undefined if (isAbsoluteUrl(url)) return url const baseUrl = buildBaseUrl(selectedServer, specUrl) if (!isAbsoluteUrl(baseUrl)) { return new URL(url, window.location.href).href } return new URL(url, baseUrl).href } /** * Safe version of buildUrl function. `selectedServer` can contain server variables * which can fail the URL resolution. */ export function safeBuildUrl(url, specUrl, { selectedServer="" } = {}) { try { return buildUrl(url, specUrl, { selectedServer }) } catch { return undefined } }