Fixed extension filter

This commit is contained in:
Simon Cambier
2023-05-18 15:14:26 +02:00
parent a2853fa2fd
commit b5c1d31e85

View File

@@ -201,13 +201,16 @@ export class Omnisearch {
logDebug('Found', results.length, 'results') logDebug('Found', results.length, 'results')
// Filter query results to only keep files that match query.extensions (if any) // Filter query results to only keep files that match query.query.ext (if any)
if (query.extensions.length) { if (query.query.ext?.length) {
results = results.filter(r => { results = results.filter(r => {
// ".can" should match ".canvas" // ".can" should match ".canvas"
const ext = '.' + r.id.split('.').pop() 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 // Filter query results that match the path
@@ -219,7 +222,8 @@ export class Omnisearch {
) )
} }
if (query.query.exclude.path) { if (query.query.exclude.path) {
results = results.filter(r => results = results.filter(
r =>
!query.query.exclude.path?.some(p => !query.query.exclude.path?.some(p =>
(r.id as string).toLowerCase().includes(p.toLowerCase()) (r.id as string).toLowerCase().includes(p.toLowerCase())
) )