From cc54158f09b057032f44ab6a5ab02933cda09417 Mon Sep 17 00:00:00 2001 From: Gness Erquint Date: Wed, 19 Mar 2025 21:17:42 +0300 Subject: [PATCH] Use Node.js path parser to extract the stem in the chats search. --- src/endpoints/chats.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/endpoints/chats.js b/src/endpoints/chats.js index fabbcf8bb..a75b11b84 100644 --- a/src/endpoints/chats.js +++ b/src/endpoints/chats.js @@ -785,9 +785,9 @@ router.post('/search', validateAvatarUrlMiddleware, function (request, response) // Search through title and messages of the chat const fragments = query.trim().toLowerCase().split(/\s+/).filter(x => x); - const text = [chatFile.path.split(/[\\/]/).pop().replace(/.jsonl$/, ''), - ...messages.map(message => message?.mes)].join('\n').toLowerCase(); - const hasMatch = fragments.every(fragment => text.includes(fragment)); + const text = [path.parse(chatFile.path).name, + ...messages.map(message => message?.mes)].join("\n").toLowerCase(); + const hasMatch = fragments.every(fragment => (text).includes(fragment)); if (hasMatch) { results.push({