From c97c88f16af2d04c907fed4eead1dbb28755d845 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 7 Jan 2025 02:36:02 +0100 Subject: [PATCH] filename link: exact match last uri segment --- .../components/markdown/StyledMarkdownPreview.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/gui/src/components/markdown/StyledMarkdownPreview.tsx b/gui/src/components/markdown/StyledMarkdownPreview.tsx index 66ceb2395..acac40ae3 100644 --- a/gui/src/components/markdown/StyledMarkdownPreview.tsx +++ b/gui/src/components/markdown/StyledMarkdownPreview.tsx @@ -298,10 +298,16 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( if (content) { // Insert file links for matching previous context items - if (previousFileContextItemsRef.current?.length) { - const ctxItem = previousFileContextItemsRef.current.find((item) => - item.uri!.value!.endsWith(content), + // With some reasonable limitations on what might be a filename + if ( + previousFileContextItemsRef.current?.length && + content.includes(".") && + content.length > 2 + ) { + const ctxItem = previousFileContextItemsRef.current.find( + (item) => item.uri!.value!.split("/").pop() === content, // Exact match for last segment of URI ); + if (ctxItem) { const rif = ctxItemToRifWithContents(ctxItem); return ;