File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 11import { isMobile } from '../util/env' ;
22import * as dom from '../util/dom' ;
3+ import { removeParams } from '../router/util' ;
34import config from '../config' ;
45import Tweezer from 'tweezer.js' ;
56
@@ -59,8 +60,7 @@ function highlight(path) {
5960 return ;
6061 }
6162
62- const li =
63- nav [ getNavKey ( decodeURIComponent ( path ) , last . getAttribute ( 'data-id' ) ) ] ;
63+ const li = nav [ getNavKey ( path , last . getAttribute ( 'data-id' ) ) ] ;
6464
6565 if ( ! li || li === active ) {
6666 return ;
@@ -86,7 +86,7 @@ function highlight(path) {
8686}
8787
8888function getNavKey ( path , id ) {
89- return `${ path } ?id=${ id } ` ;
89+ return `${ decodeURIComponent ( path ) } ?id=${ decodeURIComponent ( id ) } ` ;
9090}
9191
9292export function scrollActiveSidebar ( router ) {
@@ -127,7 +127,7 @@ export function scrollActiveSidebar(router) {
127127 return ;
128128 }
129129
130- const path = router . getCurrentPath ( ) ;
130+ const path = removeParams ( router . getCurrentPath ( ) ) ;
131131 dom . off ( 'scroll' , ( ) => highlight ( path ) ) ;
132132 dom . on ( 'scroll' , ( ) => highlight ( path ) ) ;
133133 dom . on ( sidebar , 'mouseover' , ( ) => {
Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ export const isAbsolutePath = cached(path => {
4444 return / ( : | ( \/ { 2 } ) ) / g. test ( path ) ;
4545} ) ;
4646
47+ export const removeParams = cached ( path => {
48+ return path . split ( / [ ? # ] / ) [ 0 ] ;
49+ } ) ;
50+
4751export const getParentPath = cached ( path => {
4852 if ( / \/ $ / g. test ( path ) ) {
4953 return path ;
You can’t perform that action at this time.
0 commit comments