JSFiddle - React, Tailwind, and code Playground
JavaScript
const url = new URL('/path/index.html', 'http://example.com');
console.log(url.href); // => 'http://example.com/path/index.html'
const url = new URL('/path/index.html', 'http://example.com');
console.log(url.href); // => 'http://example.com/path/index.html'