From ad6767949c65e788c071759591b9eabac51b5cf7 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Tue, 18 Feb 2014 06:26:09 +0000 Subject: chore(docs): cope with trailing slash and "index" in URLs Closes #6295 --- docs/app/src/docs.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/app/src/docs.js b/docs/app/src/docs.js index 5f9543d6..fda18e57 100644 --- a/docs/app/src/docs.js +++ b/docs/app/src/docs.js @@ -76,11 +76,26 @@ angular.module('docsApp', [ $scope.$watch(function docsPathWatch() {return $location.path(); }, function docsPathWatchAction(path) { - // Strip off leading slash - if ( path.charAt(0)==='/' ) { + + var currentPage = $scope.currentPage = NG_PAGES[path]; + if ( !currentPage && path.charAt(0)==='/' ) { + // Strip off leading slash path = path.substr(1); } - var currentPage = $scope.currentPage = NG_PAGES[path]; + + currentPage = $scope.currentPage = NG_PAGES[path]; + if ( !currentPage && path.charAt(path.length-1) === '/' && path.length > 1 ) { + // Strip off trailing slash + path = path.substr(0, path.length-1); + } + + currentPage = $scope.currentPage = NG_PAGES[path]; + if ( !currentPage && /\/index$/.test(path) ) { + // Strip off index from the end + path = path.substr(0, path.length - 6); + } + + currentPage = $scope.currentPage = NG_PAGES[path]; if ( currentPage ) { $scope.currentArea = currentPage && NG_NAVIGATION[currentPage.area]; -- cgit v1.2.3