From b5c1d31e85e64bf4b6827dbd5b95cb580b16b085 Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Thu, 18 May 2023 15:14:26 +0200 Subject: [PATCH] Fixed extension filter --- src/search/omnisearch.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/search/omnisearch.ts b/src/search/omnisearch.ts index c1ecf06..3094682 100644 --- a/src/search/omnisearch.ts +++ b/src/search/omnisearch.ts @@ -201,13 +201,16 @@ export class Omnisearch { logDebug('Found', results.length, 'results') - // Filter query results to only keep files that match query.extensions (if any) - if (query.extensions.length) { + // Filter query results to only keep files that match query.query.ext (if any) + if (query.query.ext?.length) { results = results.filter(r => { // ".can" should match ".canvas" const ext = '.' + r.id.split('.').pop() - return query.extensions.some(e => ext.startsWith(e)) + return query.query.ext?.some(e => + ext.startsWith(e.startsWith('.') ? e : '.' + e) + ) }) + console.log(query.query.ext, results.length) } // Filter query results that match the path @@ -219,10 +222,11 @@ export class Omnisearch { ) } if (query.query.exclude.path) { - results = results.filter(r => - !query.query.exclude.path?.some(p => - (r.id as string).toLowerCase().includes(p.toLowerCase()) - ) + results = results.filter( + r => + !query.query.exclude.path?.some(p => + (r.id as string).toLowerCase().includes(p.toLowerCase()) + ) ) }