Skip to main content
URL.parse - url - Node documentation
method URL.parse

Usage in Deno

import { URL } from "node:url";
URL.parse(
input: string,
base?: string,
): URL | null

Parses a string as a URL. If base is provided, it will be used as the base URL for the purpose of resolving non-absolute input URLs. Returns null if input is not a valid.

Parameters

input: string

The absolute or relative input URL to parse. If input is relative, then base is required. If input is absolute, the base is ignored. If input is not a string, it is converted to a string first.

optional
base: string

The base URL to resolve against if the input is not absolute. If base is not a string, it is converted to a string first.

Return Type

URL | null