requireLink()function

requireLink(href: PossibleLink, url?: ImmutableURL, root?: ImmutableURL, caller: AnyCaller = requireLink): ImmutableURI
ParamType
hrefPossibleLink
The link to resolve. required
urlImmutableURL
The current page URL — base for relative refs and scheme-prefixed URIs.
    .hrefURLString
A URL string has a protocol and a //. required readonly
    .originURLString
A URL string has a protocol and a //. required readonly
    .pathnameAbsolutePath
Absolute path string starting with a / slash. required readonly
rootImmutableURL
The site root URL — base for absolute paths. Defaults to url.
    .hrefURLString
A URL string has a protocol and a //. required readonly
    .originURLString
A URL string has a protocol and a //. required readonly
    .pathnameAbsolutePath
Absolute path string starting with a / slash. required readonly
callerAnyCaller
Function to attribute a thrown error to (defaults to requireLink itself). Defaults to requireLink
Return
ImmutableURI
An absolute URI string.
Throws
RequiredError
If href cannot be resolved.

Resolve a possible link to an absolute URI string, or throw RequiredError if resolution fails.

Same classification and defaults as getLink(). Use when an absolute URI is required and there's no sensible "do nothing" path for the caller.

Examples

requireLink("mailto:a@b") // → "mailto:a@b"