PHPのparse_url関数のようなもの。
var url ="https://example.com/dir1/dir2/index.php?aaa=111/bbb&bbb=7#hello";
var protocol= url.split(':')[0];
var hash = url.split('#')[1];
var query = url.split('#')[0].split('?')[1];
var host = url.split('#')[0].split('?')[0].split('/')[2];
var path = url.split('#')[0].split('?')[0].replace(host,"").replace(/^https*:[\/]{3}/,"");
console.log( protocol ); // https
console.log( host ); // example.com
console.log( path ); // dir1/dir2/index.php
console.log( query ); // aaa=111/bbb&bbb=7
console.log( hash ); // hello