title: How do I parse a URL into hostname and path in javascript?
body: <p>I would like to take a string</p>
  
  <pre><code>var a = "http://example.com/aa/bb/"
  </code></pre>
  
  <p>and process it into an object such that</p>
  
  <pre><code>a.hostname == "example.com"
  </code></pre>
  
  <p>and</p>
  
  <pre><code>a.pathname == "/aa/bb"
  </code></pre>