fix: Improve matching on quoted queries

This commit is contained in:
Tom Moor
2025-02-12 21:32:30 -05:00
parent 82539cc348
commit 854fbca420
2 changed files with 5 additions and 2 deletions

View File

@@ -877,7 +877,7 @@ describe("SearchHelper", () => {
"this&is&a&test:*"
);
});
test("should now wildcard quoted queries", () => {
test("should not wildcard quoted queries", () => {
expect(SearchHelper.webSearchQuery(`"this is a test"`)).toBe(
`"this<->is<->a<->test"`
);

View File

@@ -470,7 +470,7 @@ export default class SearchHelper {
const likelyUrls = getUrls(options.query);
// remove likely urls, and escape the rest of the query.
const limitedQuery = this.escapeQuery(
let limitedQuery = this.escapeQuery(
likelyUrls
.reduce((q, url) => q.replace(url, ""), options.query)
.slice(0, this.maxQueryLength)
@@ -482,6 +482,9 @@ export default class SearchHelper {
(match) => match[1]
);
// remove quoted queries from the limited query
limitedQuery = limitedQuery.replace(/"([^"]*)"/g, "");
const iLikeQueries = [...quotedQueries, ...likelyUrls].slice(0, 3);
for (const match of iLikeQueries) {