Dev Helpers
← Back

Resolve a relative URL

Resolve a relative URL using Node.js.

Open this example in the interactive library

Source code

import {
  URL,
  domainToASCII,
  domainToUnicode,
  pathToFileURL,
  fileURLToPath,
} from "node:url";
console.log(new URL("../logo.svg", "https://example.org/docs/start/").href);

Sample output

https://example.org/docs/logo.svg