Clone an existing URL object.
Get the URLs origin including scheme, host, and possibly username, password and port if available. In contrast to the default URL.origin property, this method returns the origin for custom schemes, for example 'com.colibrio://'.
The URL to get the origin for.
Get the origin + path of the given URL. That is, the full url minus the 'query' and 'hash' parts.
Get the relative path to url
from baseUrl
, only if url is a subpath to baseUrl.
Example:
const url = new URL('http://a.com/basePath/images/cover.jpg');
const baseUrl = new URL('http://a.com/basePath/');
const subpath = URLUtils.getSubpath(url, baseUrl);
// subpath is: 'images/cover.jpg'
Get the URL as a string but without the 'hash' part if any.
Compares two URLs and returns true if they have a common scheme, host, port and that the url's path starts with the path specified in the baseUrl.
It does not consider username/password, query or fragment.
Checks if the string can be parsed as an URL.
Returns a new URL where the percent encoding of URL.pathname
has been normalized.
In contrast to decodeURIComponent, this method does not throw an error if an invalid percent encoding is found.
Normalize percent encoding for the URL.pathname. In contrast to decodeURIComponent, this method does not throw an error if an invalid percent encoding is found.
Generated using TypeDoc
Various utility methods for URLs.