Skip to content

Commit af7448f

Browse files
committed
Add baseURL into currentRoute logic
1 parent e06fd70 commit af7448f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

addon/services/docs-routes.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ export default Service.extend({
3737

3838
currentRouteIndex: computed('router.router.currentURL', 'routeUrls.[]', function() {
3939
if (this.get('routeUrls.length')) {
40-
let currentURL = this.get('router.router.currentURL').replace(/\/$/, "");
40+
let router = this.get('router.router');
41+
let currentURL = router.get('rootURL') + router.get('currentURL');
42+
currentURL = currentURL
43+
.replace("//", "/") // dedup slashes
44+
.replace(/\/$/, ""); // remove trailing slash
4145
let index = this.get('routeUrls').indexOf(currentURL);
4246
assert(`DocsRoutes wasn't able to correctly detect the current route.`, index > -1);
4347
return index;
@@ -59,5 +63,5 @@ export default Service.extend({
5963
return this.get('routes')[(currentIndex - 1)];
6064
}
6165
})
62-
66+
6367
});

0 commit comments

Comments
 (0)