Skip to content

Instantly share code, notes, and snippets.

@dylanvaughn
Forked from thomseddon/gist:3834721
Created March 18, 2013 21:14
Show Gist options
  • Save dylanvaughn/5190867 to your computer and use it in GitHub Desktop.
Save dylanvaughn/5190867 to your computer and use it in GitHub Desktop.
var buggyAndroid = parseInt((/android (\d+)/.exec(window.navigator.userAgent.toLowerCase()) || [])[1], 10) < 4;
if (!history.pushState || buggyAndroid) {
if (window.location.hash) {
if(window.location.pathname !== '/') window.location.replace('/#!' + window.location.hash.substr(2)); //Hash and a path, just keep the hash (redirect)
} else {
window.location.replace('/#!' + window.location.pathname + window.location.search); //No hash, take path
}
}
//And then in app.config:
//$locationProvider.html5Mode(true).hashPrefix('!');
@dylanvaughn
Copy link
Author

Updated to also include query string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment