-
-
Notifications
You must be signed in to change notification settings - Fork 0
url string
Nicholas Berlette edited this page Jun 19, 2025
·
1 revision
function isURLString(it: unknown): it is URLString;
Checks if a value is a string that is a valid, parsable URL capable of being
passed to the URL
constructor.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a URL string, false
otherwise.
Web APIs
import { isURLString } from "jsr:@nick/is/url-string";
console.log(isURLString("https://example.com")); // true
console.log(isURLString("data:")); // true
console.log(isURLString("https://foo")); // false
console.log(isURLString("example.com")); // false
export type URLString = Brand<string, "URL">;
A string that is a valid, parsable URL capable of being passed to the URL
constructor. This is a branded string type, meaning it behaves as a nominal type
that is distinct from other string values. The only way to narrow a string to a
URLString
type is by validating it
first with the isURLString
type guard function.
Web APIs
Types