File tree 2 files changed +8
-4
lines changed
2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 1
1
import { isMobile } from '../util/env' ;
2
2
import * as dom from '../util/dom' ;
3
+ import { removeParams } from '../router/util' ;
3
4
import config from '../config' ;
4
5
import Tweezer from 'tweezer.js' ;
5
6
@@ -59,8 +60,7 @@ function highlight(path) {
59
60
return ;
60
61
}
61
62
62
- const li =
63
- nav [ getNavKey ( decodeURIComponent ( path ) , last . getAttribute ( 'data-id' ) ) ] ;
63
+ const li = nav [ getNavKey ( path , last . getAttribute ( 'data-id' ) ) ] ;
64
64
65
65
if ( ! li || li === active ) {
66
66
return ;
@@ -86,7 +86,7 @@ function highlight(path) {
86
86
}
87
87
88
88
function getNavKey ( path , id ) {
89
- return `${ path } ?id=${ id } ` ;
89
+ return `${ decodeURIComponent ( path ) } ?id=${ decodeURIComponent ( id ) } ` ;
90
90
}
91
91
92
92
export function scrollActiveSidebar ( router ) {
@@ -127,7 +127,7 @@ export function scrollActiveSidebar(router) {
127
127
return ;
128
128
}
129
129
130
- const path = router . getCurrentPath ( ) ;
130
+ const path = removeParams ( router . getCurrentPath ( ) ) ;
131
131
dom . off ( 'scroll' , ( ) => highlight ( path ) ) ;
132
132
dom . on ( 'scroll' , ( ) => highlight ( path ) ) ;
133
133
dom . on ( sidebar , 'mouseover' , ( ) => {
Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ export const isAbsolutePath = cached(path => {
44
44
return / ( : | ( \/ { 2 } ) ) / g. test ( path ) ;
45
45
} ) ;
46
46
47
+ export const removeParams = cached ( path => {
48
+ return path . split ( / [ ? # ] / ) [ 0 ] ;
49
+ } ) ;
50
+
47
51
export const getParentPath = cached ( path => {
48
52
if ( / \/ $ / g. test ( path ) ) {
49
53
return path ;
You can’t perform that action at this time.
0 commit comments