formatURL()function

formatURL(url: PossibleURL, base?: PossibleURL, caller: AnyCaller = formatURL): string
ParamType
urlPossibleURL
URL to format. required
basePossibleURL
Base URL to resolve url against if it is relative.
callerAnyCaller
Function to attribute a thrown error to (defaults to formatURL itself). Defaults to formatURL
Return
string
Friendly string showing the host and path with any trailing slash removed.
Throws
RequiredError
If url cannot be converted to a valid URL.

Format a URL as a user-friendly string.

  • e.g. http://shax.com/test?uid=129483shax.com/test

Examples

formatURL("http://shax.com/test?uid=129483") // "shax.com/test"