Use Node.js path parser to extract the stem in the chats search.

This commit is contained in:
Gness Erquint
2025-03-19 21:17:42 +03:00
parent 190f2f9085
commit cc54158f09

View File

@@ -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({