method URL.canParse
Usage
import { URL } from "node:url";
Checks if an input relative to the base can be parsed to a URL.
const isValid = URL.canParse('/foo', 'https://example.org/'); // true const isNotValid = URL.canParse('/foo'); // false