Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit ad67679

Browse files
chore(docs): cope with trailing slash and "index" in URLs
Closes #6295
1 parent 2407891 commit ad67679

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

docs/app/src/docs.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,26 @@ angular.module('docsApp', [
7676

7777

7878
$scope.$watch(function docsPathWatch() {return $location.path(); }, function docsPathWatchAction(path) {
79-
// Strip off leading slash
80-
if ( path.charAt(0)==='/' ) {
79+
80+
var currentPage = $scope.currentPage = NG_PAGES[path];
81+
if ( !currentPage && path.charAt(0)==='/' ) {
82+
// Strip off leading slash
8183
path = path.substr(1);
8284
}
83-
var currentPage = $scope.currentPage = NG_PAGES[path];
85+
86+
currentPage = $scope.currentPage = NG_PAGES[path];
87+
if ( !currentPage && path.charAt(path.length-1) === '/' && path.length > 1 ) {
88+
// Strip off trailing slash
89+
path = path.substr(0, path.length-1);
90+
}
91+
92+
currentPage = $scope.currentPage = NG_PAGES[path];
93+
if ( !currentPage && /\/index$/.test(path) ) {
94+
// Strip off index from the end
95+
path = path.substr(0, path.length - 6);
96+
}
97+
98+
currentPage = $scope.currentPage = NG_PAGES[path];
8499

85100
if ( currentPage ) {
86101
$scope.currentArea = currentPage && NG_NAVIGATION[currentPage.area];

0 commit comments

Comments
 (0)