getURL()function
getURL(target: Nullish<PossibleURL>, base?: PossibleURL): ImmutableURL | undefined
| Param | Type | |
|---|---|---|
target | Nullish<PossibleURL> | URL string, URL object, or path to resolve — falsy values return undefined. required |
base | PossibleURL | Base URL to resolve a relative target against. |
| Return | |
|---|---|
ImmutableURL | undefined | Resolved ImmutableURL, or undefined if conversion fails or the result is not a true URL. |
Resolve a possible URL relative to a base URL, or return undefined if conversion fails.
- Like
getBasedURI()but only succeeds for truescheme://hostURLs — other URIs (e.g.mailto:) returnundefined.
Examples
getURL("/page", "http://example.com/"); // `http://example.com/page`
getURL("mailto:[email protected]"); // `undefined` — not a hierarchical URL