From 3ff06fe0337df7a037e01e642dd4bde334b152c1 Mon Sep 17 00:00:00 2001 From: rock G <35254251+GGXXLL@users.noreply.github.com> Date: Tue, 6 Dec 2022 04:21:37 +0800 Subject: [PATCH] fix: anchor link need decode (#719) --- assets/ts/smoothAnchors.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/ts/smoothAnchors.ts b/assets/ts/smoothAnchors.ts index 46a4a03..16ab6a3 100644 --- a/assets/ts/smoothAnchors.ts +++ b/assets/ts/smoothAnchors.ts @@ -21,8 +21,8 @@ function setupSmoothAnchors() { aElement.addEventListener("click", clickEvent => { clickEvent.preventDefault(); - const targetId = aElement.getAttribute("href").substring(1), - target = document.getElementById(targetId) as HTMLElement, + const targetId = decodeURI(aElement.getAttribute("href").substring(1)), + target = document.getElementById(targetId) as HTMLElement, offset = target.getBoundingClientRect().top - document.documentElement.getBoundingClientRect().top; window.history.pushState({}, "", aElement.getAttribute("href"));