Methods

(static) getBaseUrl(url) → {string}

Extract base URL (scheme + authority) from a full URL

Parameters:
NameTypeDescription
urlstring

The full URL

Returns:

Base URL (e.g., "https://example.com:8096"), or empty string if invalid

Type: 
string

(static) getServerBaseUrl(url, endpointPath) → {string}

Extract server base URL by removing a known endpoint path suffix This preserves any base path (e.g., /jellyfin) unlike getBaseUrl() which strips all paths

Parameters:
NameTypeDescription
urlstring

The full URL (e.g., "https://host/jellyfin/system/info/public")

endpointPathstring

The endpoint path to remove (e.g., "/system/info/public")

Returns:

Base URL with preserved path (e.g., "https://host/jellyfin"), or empty string if invalid

Type: 
string

(static) mergePaths(basePath, relPath) → {string}

Merge a relative path with a base path

Parameters:
NameTypeDescription
basePathstring

The base path (directory)

relPathstring

The relative path to merge

Returns:

Merged path string

Type: 
string

(static) normalizeUrl(url) → {string}

Normalize a URL for consistent comparison and storage

  • Lowercase scheme
  • Remove default ports (:80 for http, :443 for https)
  • Remove trailing slash from path (except root)
  • Remove empty query strings
Parameters:
NameTypeDescription
urlstring

The URL to normalize

Returns:

Normalized URL string, or empty string if invalid

Type: 
string

(static) parseUrlComponents(url) → {object}

Parse URL into components

Parameters:
NameTypeDescription
urlstring

The URL to parse

Returns:

Associative array with scheme, authority, host, port, path, query, or invalid

Type: 
object

(static) reconstructUrl(parts) → {string}

Reconstruct URL from parsed components

Parameters:
NameTypeDescription
partsobject

Associative array with scheme, authority, path, query

Returns:

Reconstructed URL string

Type: 
string

(static) removeDotSegments(path) → {string}

Remove dot segments from path per RFC 3986 Section 5.2.4

Parameters:
NameTypeDescription
pathstring

The path to process

Returns:

Path with dot segments removed

Type: 
string

(static) resolveUrl(baseUrl, reference) → {string}

Resolve a reference URI against a base URI per RFC 3986 Section 5 Note: Only http:// and https:// schemes are supported. Other schemes (mailto:, ftp:, etc.) will be treated as relative paths. The result is automatically normalized (lowercased scheme, default ports removed, trailing slashes stripped, etc.) for consistent comparison and storage.

Parameters:
NameTypeDescription
baseUrlstring

The base URI (absolute, http/https only)

referencestring

The reference URI (can be absolute http/https, relative, or protocol-relative)

Returns:

Resolved and normalized absolute URI string, or empty string if resolution fails

Type: 
string

(static) urlsEqual(url1, url2) → {boolean}

Check if two URLs are equivalent after normalization

Parameters:
NameTypeDescription
url1string

First URL

url2string

Second URL

Returns:

true if URLs are equivalent, false otherwise

Type: 
boolean