diff --git a/server/models/helpers/SearchHelper.test.ts b/server/models/helpers/SearchHelper.test.ts index aa5323e878..03dc311a3a 100644 --- a/server/models/helpers/SearchHelper.test.ts +++ b/server/models/helpers/SearchHelper.test.ts @@ -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"` ); diff --git a/server/models/helpers/SearchHelper.ts b/server/models/helpers/SearchHelper.ts index c63e966f6c..28a393696b 100644 --- a/server/models/helpers/SearchHelper.ts +++ b/server/models/helpers/SearchHelper.ts @@ -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) {