Skip to content

Instantly share code, notes, and snippets.

@richardroyal
Created December 21, 2016 19:05
Show Gist options
  • Save richardroyal/f37915bd6ace4e2f7309252b7ef349e8 to your computer and use it in GitHub Desktop.
Save richardroyal/f37915bd6ace4e2f7309252b7ef349e8 to your computer and use it in GitHub Desktop.
(function () {
var cleanPath, newUrl,
location = window.location,
history = window.history;
if (history && history.pushState) {
cleanPath = ['pathname', 'search', 'hash'].map(function (key) {
return location[key].replace(/@.+\.[A-Z]{2}/ig, '');
}).join('');
newUrl = location.protocol + '//' + location.host + cleanPath;
// Only mangle when necessary.
if (location.href.indexOf(newUrl) < 0) {
history.pushState({
path: newUrl
}, '', newUrl);
}
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment