Skip to content

Commit b2dd708

Browse files
authored
Merge pull request #1146 from vagra/bugfix
Fix #1136 and #1127
2 parents 0bbc02c + b108c86 commit b2dd708

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/core/event/scroll.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { isMobile } from '../util/env';
22
import * as dom from '../util/dom';
3+
import { removeParams } from '../router/util';
34
import config from '../config';
45
import 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

8888
function getNavKey(path, id) {
89-
return `${path}?id=${id}`;
89+
return `${decodeURIComponent(path)}?id=${decodeURIComponent(id)}`;
9090
}
9191

9292
export 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', () => {

src/core/router/util.js

+4
Original file line numberDiff line numberDiff 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+
4751
export const getParentPath = cached(path => {
4852
if (/\/$/g.test(path)) {
4953
return path;

0 commit comments

Comments
 (0)