Fixed: extensions can be searched with ".foo" in addition to "ext:foo"

This commit is contained in:
Simon Cambier
2023-12-17 13:58:38 +01:00
parent 703568dab3
commit 7a2f9b0ee0

View File

@@ -46,6 +46,15 @@ export class Query {
} }
this.query = parsed this.query = parsed
// Extract keywords starting with a dot...
const ext = this.query.text
.filter(o => o.startsWith('.'))
.map(o => o.slice(1))
// add them to the ext field...
this.query.ext = [...new Set([...ext, ...(this.query.ext ?? [])])]
// and remove them from the text field
this.query.text = this.query.text.filter(o => !o.startsWith('.'))
// Get strings in quotes, and remove the quotes // Get strings in quotes, and remove the quotes
this.#inQuotes = this.#inQuotes =
text.match(/"([^"]+)"/g)?.map(o => o.replace(/"/g, '')) ?? [] text.match(/"([^"]+)"/g)?.map(o => o.replace(/"/g, '')) ?? []