Skip to content

Commit e782c4c

Browse files
committed
fix: decode hash before selecting
1 parent 7802cb5 commit e782c4c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/client/app/router.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export function createRouter(
6464
nextTick(() => {
6565
if (targetLoc.hash && !scrollPosition) {
6666
const target = document.querySelector(
67-
targetLoc.hash
67+
decodeURIComponent(targetLoc.hash)
6868
) as HTMLElement
6969
if (target) {
7070
scrollTo(target, targetLoc.hash)
@@ -150,7 +150,7 @@ function scrollTo(el: HTMLElement, hash: string, smooth = false) {
150150
const pageOffset = document.getElementById('app')!.offsetTop
151151
const target = el.classList.contains('.header-anchor')
152152
? el
153-
: document.querySelector(hash)
153+
: document.querySelector(decodeURIComponent(hash))
154154
if (target) {
155155
const targetTop = (target as HTMLElement).offsetTop - pageOffset - 15
156156
// only smooth scroll if distance is smaller than screen height.

0 commit comments

Comments
 (0)