Skip to content

Instantly share code, notes, and snippets.

View radubrehar's full-sized avatar

Radu Brehar radubrehar

View GitHub Profile
@radubrehar
radubrehar / uri.js
Created September 20, 2012 11:53 — forked from jlong/uri.js
URI Parsing with Javascript - current window location
var parser = document.createElement('a');
parser.href = window.location.href;
//if the current page location is "http://example.com:3000/pathname/?search=test#hash";
//we get the following
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
@radubrehar
radubrehar / uri.js
Created April 26, 2012 13:15 — forked from jlong/uri.js
URI Parsing with Javascript
var 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"