Deconstruct URL (quick regex)
window.location.href.match(/^([^/]+):\/\/([^/:]+):?([1-9]*)\/([^?]*)\??(.*)$/)
Example output:
["http://127.0.0.1:1337/projects/sd?sdflkj&jh", "http", "127.0.0.1", "1337", "projects/sd", "sdflkj&jh"]
That is: full match, protocol, host, port, path (relative to root), query string
Todo: test for bugs.