Improving quotes to allow "hyphenated-words"

This commit is contained in:
Simon Cambier
2023-06-18 10:05:26 +02:00
parent 5c3d8277e7
commit be2a724c0c

View File

@@ -9,11 +9,10 @@ type Keywords = {
} & { text: string[] }
export class Query {
query: Keywords & { exclude: Keywords }
/**
* @deprecated
*/
extensions: string[] = []
query: Keywords & {
exclude: Keywords
}
#inQuotes: string[]
constructor(text = '') {
if (settings.ignoreDiacritics) {
@@ -44,7 +43,10 @@ export class Query {
}
}
this.query = parsed
this.extensions = this.query.ext ?? []
// Get strings in quotes, and remove the quotes
this.#inQuotes =
text.match(/"([^"]+)"/g)?.map(o => o.replace(/"/g, '')) ?? []
}
public isEmpty(): boolean {
@@ -72,6 +74,11 @@ export class Query {
}
public getExactTerms(): string[] {
return this.query.text.filter(o => o.split(' ').length > 1)
return [
...new Set([
...this.query.text.filter(o => o.split(' ').length > 1),
...this.#inQuotes,
]),
]
}
}