assertURL()function

assertURL(value: unknown, caller: AnyCaller = assertURL): asserts value is ImmutableURL
ParamType
valueunknown
Unknown value to test. required
callerAnyCaller
Function to attribute a thrown error to — defaults to assertURL. Defaults to assertURL
Return
asserts value is ImmutableURL
Throws
unknown
RequiredError If value is not a true scheme://host URL object.

Assert that an unknown value is a URL object.

Examples

assertURL(value);
value.pathname; // `value` is narrowed to `ImmutableURL`