Turn a URL into just the path + querystring
// normalizeUrl('http://news.bbc.co.uk/sport/?page=1#test');
// returns "/sport/?page=1"
var normalizeUrl = function (url) {
var a = document.createElement('a');
a.href = url;
a = a.pathname + a.search;
a = a.indexOf('/') === 0 ? a : '/' + a; // because IE doesn't return a leading '/'
return a;
};