From 9585c6a55f1375ffda73fb5a81917ae7d7800ce2 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 28 Mar 2025 22:22:42 +0200 Subject: [PATCH] fix(client): "Note not found" tooltip for some URLs --- src/public/app/services/link.spec.ts | 10 ++++++++++ src/public/app/services/link.ts | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/public/app/services/link.spec.ts b/src/public/app/services/link.spec.ts index 984822a50..60812ccf9 100644 --- a/src/public/app/services/link.spec.ts +++ b/src/public/app/services/link.spec.ts @@ -6,4 +6,14 @@ describe("Link", () => { const output = parseNavigationStateFromUrl("http://localhost:8080/#?searchString=hello"); expect(output).toMatchObject({ searchString: "hello" }); }); + + it("parses searchString with hash", () => { + const output = parseNavigationStateFromUrl("https://github.com/orgs/TriliumNext/discussions/1526#discussioncomment-12656660"); + expect(output).toStrictEqual({}); + }); + + it("parses notePath", () => { + const output = parseNavigationStateFromUrl(`#root/WWaBNf3SSA1b/mQ2tIzLVFKHL`); + expect(output).toMatchObject({ notePath: "root/WWaBNf3SSA1b/mQ2tIzLVFKHL", noteId: "mQ2tIzLVFKHL" }); + }); }); diff --git a/src/public/app/services/link.ts b/src/public/app/services/link.ts index 3d92ac819..df511f2c7 100644 --- a/src/public/app/services/link.ts +++ b/src/public/app/services/link.ts @@ -238,10 +238,14 @@ export function parseNavigationStateFromUrl(url: string | undefined) { } } - if (!notePath.match(/^[_a-z0-9]{4,}(\/[_a-z0-9]{4,})*$/i)) { + if (searchString) { return { searchString } } + if (!notePath.match(/^[_a-z0-9]{4,}(\/[_a-z0-9]{4,})*$/i)) { + return {}; + } + return { notePath, noteId: treeService.getNoteIdFromUrl(notePath),