Dev Helpers
← Back

Validate a URL before parsing

Validate a URL before parsing using Node.js.

Open this example in the interactive library

Source code

import {
  URL,
  domainToASCII,
  domainToUnicode,
  pathToFileURL,
  fileURLToPath,
} from "node:url";
console.log(URL.canParse("/help", "https://example.org"));

Sample output

true