title: Generate canonical / real URL based on base.href or location
body: <p>Is there a method/function to get the canonical / transformed URL, respecting any base.href setting of the page?</p>
  
  <p>I can get the base URL via (in jQuery) using <code>$("base").attr("href")</code> and I could use string methods to parse the URL meant to being made relative to this, but</p>
  
  <ul>
  <li>$("base").attr("href") has no host, path etc attributes (like window.location has)</li>
  <li>manually putting this together is rather tedious</li>
  </ul>
  
  <p>E.g., given a base.href of <code>"http://example.com/foo/"</code> and a relative URL <code>"/bar.js"</code>, the result should be: <code>"http://example.com/bar.js"</code></p>
  
  <p>If base.href is not present, the URL should be made relative to window.location.
  This should handle non-existing base.href (using location as base in this case).</p>
  
  <p>Is there a standard method available for this already?</p>
  
  <p>(I'm looking for this, since jQuery.getScript fails when using a relative URL like "/foo.js" and BASE tag is being used (FF3.6 makes an OPTIONS request, and nginx cannot handle this). When using the full URL (base.href.host + "/foo.js", it works).)</p>