diff options
| author | Peter Bacon Darwin | 2014-02-18 06:26:09 +0000 |
|---|---|---|
| committer | Peter Bacon Darwin | 2014-02-18 06:26:24 +0000 |
| commit | ad6767949c65e788c071759591b9eabac51b5cf7 (patch) | |
| tree | 00d86c5db5948afdcb2463ff9477a331dd4653e0 | |
| parent | 2407891ddf2d99b08106ceeaed7ae4f16ee0d760 (diff) | |
| download | angular.js-ad6767949c65e788c071759591b9eabac51b5cf7.tar.bz2 | |
chore(docs): cope with trailing slash and "index" in URLs
Closes #6295
| -rw-r--r-- | docs/app/src/docs.js | 21 |
1 files 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]; |
