I would like to take a string
var a = \"http://example.com/aa/bb/\"
and process it into an object such that
a.hostname == \
Stop reinventing the wheel. Use https://github.com/medialize/URI.js/
var uri = new URI("http://example.org:80/foo/hello.html"); // get host uri.host(); // returns string "example.org:80" // set host uri.host("example.org:80");