Skip to content

Instantly share code, notes, and snippets.

@chirag64
Forked from jlong/uri.js
Last active August 29, 2015 14:05
Show Gist options
  • Save chirag64/d9a209d3fe21929791ee to your computer and use it in GitHub Desktop.
Save chirag64/d9a209d3fe21929791ee to your computer and use it in GitHub Desktop.
// var parser = document.createElement('a');
// parser.href = "http://user:secretpassword@example.com:3000/pathname/?search=test#hash";
// OR
var parser = new URL("http://user:secretpassword@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"
parser.username // => "user"
parser.password // => "secretpassword"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment