Open this example in the interactive library
Source code
console.log(
new URL("../image.png", "https://example.com/docs/page/").href,
);
Sample output
https://example.com/docs/image.png

Resolve a relative URL. A self-contained example using the JavaScript runtime.
Open this example in the interactive library
console.log(
new URL("../image.png", "https://example.com/docs/page/").href,
);
https://example.com/docs/image.png