URL オブジェクトの各プロパティが実際にどのような内容になるか調べてみました。
空文字列以外はクオートを省略してあります。
var u = new URL ('http://example.com:8080/dir/index.html?q=1#frag');
alert ([
u.url, // http://example.com:8080/dir/index.html?q=1#frag
u.protocol, // http
u.host, // example.com:8080
u.hostname, // example.com
u.port, // 8080
u.path, // /dir/index.html?q=1#frag
u.directory, // /dir/
u.filename, // index.html
u.query // ?q=1#frag
].join ("\n"));
最小限の構成要素だと以下のようになります。
var u = new URL ('https://example.com/');
alert ([
u.url, // https://example.com/
u.protocol, // https
u.host, // example.com
u.hostname, // example.com
u.port, // ''
u.path, // /
u.directory, // ''
u.filename, // ''
u.query // ''
].join ("\n"));