File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,24 @@ document.addEventListener('DOMContentLoaded', function() {
1010 const parentUrlObj = new URL ( parentUrl ) ;
1111
1212 // Compare the pathname (ignoring hash and query parameters)
13- if ( linkUrl . pathname === parentUrlObj . pathname ) {
13+ const linkPath = linkUrl . pathname ;
14+ const parentPath = parentUrlObj . pathname ;
15+
16+ // Check for direct match first
17+ let isMatch = linkPath === parentPath ;
18+
19+ if ( ! isMatch ) {
20+ // If no direct match and parent path doesn't end with a file, try appending index.html
21+ const lastSegment = parentPath . split ( '/' ) . pop ( ) ;
22+ const endsWithFile = lastSegment && lastSegment . includes ( '.' ) ;
23+
24+ if ( ! endsWithFile ) {
25+ isMatch = linkPath === parentPath + 'index.html' ||
26+ linkPath === parentPath . replace ( / \/ $ / , '' ) + '/index.html' ;
27+ }
28+ }
29+
30+ if ( isMatch ) {
1431 link . parentElement . classList . add ( 'current-page' ) ;
1532 currentPageElement = link . parentElement ;
1633 }
You can’t perform that action at this time.
0 commit comments