Parameters
- input: string | URL | Readonly<Pick<{
fullPath: string;
hash: string;
host: string;
hostname: string;
href: string;
origin: string;
password: string;
pathname: string;
paths: string[];
port: string;
protocol: string;
search: string;
searchParams: Required<Record<string, string[]>>;
username: string;
}, "href">>
Returns string | undefined
Url string if input can be parsed. Otherwise, undefined
.
Attempt to convert the input input a valid URL string via the
URL
class. If the conversion fails,undefined
is returned. Note that this is pretty strict: many values which can be correctly handled byparseUrl
will fail this. (For example, the protocol must be included for this to pass.)