Skip to content

Instantly share code, notes, and snippets.

@hiroshido
Created August 14, 2014 08:30
Show Gist options
  • Save hiroshido/b8244c597267619bc819 to your computer and use it in GitHub Desktop.
Save hiroshido/b8244c597267619bc819 to your computer and use it in GitHub Desktop.
AngularJSでURL末尾の"/"スラッシュを削除 ref: http://qiita.com/unamu/items/c0cba8ace1cd1cc11b94
$urlRouterProvider.rule(function ($injector, $location) {
var path = $location.url()
// check to see if the path has a trailing slash
if ('/' === path[path.length - 1]) return path.replace(/\/$/, '')
if (path.indexOf('/?') > 0) return path.replace('/?', '?')
return false;
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment