Module: URLUtils

Provides utility functions for operating on URLs. Initially this is simply a method to determine the Base URL of a URL, but should probably include other things provided all over the place such as determining whether a URL is relative/absolute, resolving two paths etc.

Source:

Methods


<private> dumbURLResolver(url [, baseUrl])

Resolves a url given an optional base url Does not resolve ./, ../ etc but will do enough to construct something which will satisfy XHR etc when window.URL is not available ie IE11/node etc.

Parameters:
Name Type Argument Description
url string
baseUrl string <optional>
Source:
Returns:
Type
string

isHTTPURL(url)

Determines whether the url is an HTTP-URL as defined in ISO/IEC 23009-1:2014 3.1.15. ie URL with a fixed scheme of http or https

Parameters:
Name Type Description
url string
Source:
Returns:
Type
bool

isPathAbsolute(url)

Determines whether the url is path-absolute.

Parameters:
Name Type Description
url string
Source:
Returns:
Type
bool

isRelative(url)

Determines whether the url is relative.

Parameters:
Name Type Description
url string
Source:
Returns:
Type
bool

<private> nativeURLResolver(url [, baseUrl])

Resolves a url given an optional base url Uses window.URL to do the resolution.

Parameters:
Name Type Argument Description
url string
baseUrl string <optional>
Source:
Returns:
Type
string

parseBaseUrl(url)

Returns a string that contains the Base URL of a URL, if determinable.

Parameters:
Name Type Description
url string

full url

Source:
Returns:
Type
string

parseOrigin(url)

Returns a string that contains the scheme and origin of a URL, if determinable.

Parameters:
Name Type Description
url string

full url

Source:
Returns:
Type
string

resolve(url [, baseUrl])

Resolves a url given an optional base url

Parameters:
Name Type Argument Description
url string
baseUrl string <optional>
Source:
Returns:
Type
string