Skip to content

Build your personal knowledge base with Trilium Notes

refactor(breadcrumb): use existing function to parse note path

Elian Doranec22fd9e996b
diff --git a/apps/client/src/widgets/layout/Breadcrumb.tsx b/apps/client/src/widgets/layout/Breadcrumb.tsx
index 67775177e2..a836f8a5f8 100644
--- a/apps/client/src/widgets/layout/Breadcrumb.tsx
+++ b/apps/client/src/widgets/layout/Breadcrumb.tsx
@@ -19,6 +19,7 @@ import froca from "../../services/froca";
import hoisted_note from "../../services/hoisted_note";
import { t } from "../../services/i18n";
import note_create from "../../services/note_create";
+import tree from "../../services/tree";
import ActionButton from "../react/ActionButton";
import { Badge } from "../react/Badge";
import Dropdown from "../react/Dropdown";
@@ -268,9 +269,7 @@ function buildContextMenu(notePath: string, parentComponent: Component | null) {
return async (e: MouseEvent) => {
e.preventDefault();
- const notePathComponents = notePath.split("/");
- const parentNoteId = notePathComponents.at(-2);
- const noteId = notePathComponents.at(-1);
+ const { noteId, parentNoteId } = tree.getNoteIdAndParentIdFromUrl(notePath);
if (!parentNoteId || !noteId) return;
const branchId = await froca.getBranchId(parentNoteId, noteId);