Merge pull request #3729 from Erquint/staging

Use Node.js path parser to extract the filename stem in the chats search.
This commit is contained in:
Cohee
2025-03-19 22:07:06 +02:00
committed by GitHub

View File

@@ -785,7 +785,7 @@ router.post('/search', validateAvatarUrlMiddleware, function (request, response)
// Search through title and messages of the chat // Search through title and messages of the chat
const fragments = query.trim().toLowerCase().split(/\s+/).filter(x => x); const fragments = query.trim().toLowerCase().split(/\s+/).filter(x => x);
const text = [chatFile.path.split(/[\\/]/).pop().replace(/.jsonl$/, ''), const text = [path.parse(chatFile.path).name,
...messages.map(message => message?.mes)].join('\n').toLowerCase(); ...messages.map(message => message?.mes)].join('\n').toLowerCase();
const hasMatch = fragments.every(fragment => text.includes(fragment)); const hasMatch = fragments.every(fragment => text.includes(fragment));