url.js
Methods
-
static getAbsoluteURL(url) → {string}
-
Get absolute version of relative URL.
Parameters:
Name Type Description urlstring URL to make absolute
Returns:
string -Absolute URL
-
static getFileExtension(path) → {string}
-
Returns the extension of the passed file name. It will return an empty string if passed an invalid path.
Parameters:
Name Type Description pathstring The fileName path like '/path/to/file.mp4'
Returns:
string -The extension in lower case or an empty string if no extension could be found.
-
static isCrossOrigin(url, winLocopt) → {boolean}
-
Returns whether the url passed is a cross domain request or not.
Parameters:
Name Type Attributes Description urlstring The url to check.
winLocObject <optional>
the domain to check the url against, defaults to window.location
Properties
Name Type Attributes Description protocolstring <optional>
The window location protocol defaults to window.location.protocol
hoststring <optional>
The window location host defaults to window.location.host
Returns:
boolean -Whether it is a cross domain request or not.
-
static parseUrl(url) → {module:url~url:URLObject}
-
Resolve and parse the elements of a URL.
Parameters:
Name Type Description urlString The url to parse
Type Definitions
-
url:URLObject
-
Properties:
Name Type Description protocolstring The protocol of the url that was parsed.
hostnamestring The hostname of the url that was parsed.
portstring The port of the url that was parsed.
pathnamestring The pathname of the url that was parsed.
searchstring The search query of the url that was parsed.
hashstring The hash of the url that was parsed.
hoststring The host of the url that was parsed.