Skip to content

Commit

Permalink
docs: only re-direct when route expects a version.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus committed Sep 21, 2014
1 parent 661aaa2 commit d8c2ad7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docs/components/docs/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,13 @@ angular
.run(function($location, $route, $rootScope, versions) {
$rootScope.$on('$routeChangeStart', function(event, route) {
var url = $location.path();
if (url.indexOf('/docs/') === -1) {
if (url.indexOf('/docs/') === -1 || (!route.params || !route.params.version)) {
// This isn't a `docs` route or it's not one that expects a version.
// No need to re-direct request.
return;
}
var version = route.params && route.params.version;
if (versions.indexOf(version) === -1) {
// No version specified.
if (versions.indexOf(route.params.version) === -1) {
// No version specified where one was expected.
// Route to same url with latest version prepended.
event.preventDefault();
$route.reload();
Expand Down

0 comments on commit d8c2ad7

Please sign in to comment.