Merge pull request #2243 from TriliumNext/open_in_new_window

fix(link): Unable to open notes in a new window
This commit is contained in:
Elian Doran 2025-06-10 13:35:00 +03:00 committed by GitHub
commit cbc57c3a77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -22,6 +22,11 @@ describe("Link", () => {
expect(output).toMatchObject({ notePath: "root/WWaBNf3SSA1b/mQ2tIzLVFKHL", noteId: "mQ2tIzLVFKHL" }); 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", () => { it("ignores external URL with internal hash anchor", () => {
const output = parseNavigationStateFromUrl(`https://en.wikipedia.org/wiki/Bearded_Collie#Health`); const output = parseNavigationStateFromUrl(`https://en.wikipedia.org/wiki/Bearded_Collie#Health`);
expect(output).toMatchObject({}); expect(output).toMatchObject({});

View File

@ -218,7 +218,7 @@ export function parseNavigationStateFromUrl(url: string | undefined) {
} }
// Exclude external links that contain # // 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 {}; return {};
} }