From 885cdc8c97ec33e27adc970ae31208d444c011a4 Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Tue, 10 Jun 2025 17:25:10 +0800 Subject: [PATCH 1/2] Fix: Unable to open in a new window --- apps/client/src/services/link.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/client/src/services/link.ts b/apps/client/src/services/link.ts index 62a5a46ab..116ca8a5b 100644 --- a/apps/client/src/services/link.ts +++ b/apps/client/src/services/link.ts @@ -218,7 +218,7 @@ export function parseNavigationStateFromUrl(url: string | undefined) { } // Exclude external links that contain # - if (hashIdx !== 0 && !url.includes("/#root") && !url.includes("/#?searchString")) { + if (hashIdx !== 0 && !url.includes("/#root") && !url.includes("/#?searchString") && !url.includes("/?extraWindow")) { return {}; } From ee9267775e9adc697d8ada8e01e8676559a78a2d Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Tue, 10 Jun 2025 17:38:05 +0800 Subject: [PATCH 2/2] vitest(link): add Vitest test cases for parseNavigationStateFromUrl --- apps/client/src/services/link.spec.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/client/src/services/link.spec.ts b/apps/client/src/services/link.spec.ts index 09eaf09e7..eb52c3efc 100644 --- a/apps/client/src/services/link.spec.ts +++ b/apps/client/src/services/link.spec.ts @@ -22,6 +22,11 @@ describe("Link", () => { expect(output).toMatchObject({ notePath: "root/WWaBNf3SSA1b/mQ2tIzLVFKHL", noteId: "mQ2tIzLVFKHL" }); }); + it("parses notePath with extraWindow", () => { + const output = parseNavigationStateFromUrl(`127.0.0.1:8080/?extraWindow=1#root/QZGqKB7wVZF8?ntxId=0XPvXG`); + expect(output).toMatchObject({ notePath: "root/QZGqKB7wVZF8", noteId: "QZGqKB7wVZF8" }); + }); + it("ignores external URL with internal hash anchor", () => { const output = parseNavigationStateFromUrl(`https://en.wikipedia.org/wiki/Bearded_Collie#Health`); expect(output).toMatchObject({});