Skip to content

Instantly share code, notes, and snippets.

@dimorphic
Created May 9, 2018 08:19
Show Gist options
  • Select an option

  • Save dimorphic/b0eef2fc3532ec9ae6bb2cb1e8b82388 to your computer and use it in GitHub Desktop.

Select an option

Save dimorphic/b0eef2fc3532ec9ae6bb2cb1e8b82388 to your computer and use it in GitHub Desktop.
lazy man url parser
let parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment