Распарсиваем url с помощью javascript.
Получаем:
protocol; // => "http:"
host; // => "example.com:3000"
hostname; // => "example.com"
port; // => "3000"
pathname; // => "/pathname/"
hash; // => "#hash"
search; // => "?search=test"
origin;
var url = getLocation(location.href);
console.log(url);
function getLocation(href) {
var match = href.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
return match && {
protocol: match[1],
host: match[2],
hostname: match[3],
port: match[4],
pathname: match[5],
search: match[6],
hash: match[7]
}
}