Skip to content

Commit 546f4a6

Browse files
authored
fix(history): use encodePath for history key generation (#546)
1 parent 3edeff9 commit 546f4a6

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/store/history.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { shouldKeepState, ObjStore, objStore, State } from "~/store/obj"
22
import { getGlobalPage, setGlobalPage } from "~/hooks"
3+
import { encodePath } from "~/utils"
34

45
interface History {
56
obj: object
@@ -14,7 +15,7 @@ const waitForNextFrame = () => {
1415
}
1516

1617
export const getHistoryKey = (path: string, page?: number) => {
17-
const pathname = path.split("?")[0]
18+
const pathname = encodePath(path)
1819
return page && page > 1 ? `${pathname}?page=${page}` : pathname
1920
}
2021

@@ -69,7 +70,7 @@ document.addEventListener(
6970
let target = e.target as HTMLElement
7071
let link = target.closest("a")
7172
let path = link?.getAttribute("href")
72-
if (path) {
73+
if (path && path.startsWith("/")) {
7374
clearHistory(decodeURIComponent(path))
7475
}
7576
},

0 commit comments

Comments
 (0)