title: How do I parse a relative URL without base URL in JavaScript
body: <p>For absolute URL we can parse with <code>new URL(str)</code>; for relative URL with base URL we can have <code>new URL(path, base)</code>. How do I parse a relative URL without a base URL? For example, <code>folder/file.ext?a=1&amp;b=2#hash</code> should be parsed into</p>
  
  <pre><code>{
      pathname: "folder/file.ext",
      search: "?a=1&amp;b=2",
      hash: "#hash"
  }
  </code></pre>
  
  <p>Third-party library is fine, but I prefer built-in libraries and functions. Prefer cross-platform (browser/Node.js) solutions. No need for IE.</p>