fix: Search query backslash replacement only touched first instance
closes #2111
This commit is contained in:
@@ -248,7 +248,7 @@ type SearchOptions = {
|
||||
function escape(query: string): string {
|
||||
// replace "\" with escaped "\\" because sequelize.escape doesn't do it
|
||||
// https://github.com/sequelize/sequelize/issues/2950
|
||||
return sequelize.escape(query).replace("\\", "\\\\");
|
||||
return sequelize.escape(query).replace(/\\/g, "\\\\");
|
||||
}
|
||||
|
||||
Document.searchForTeam = async (
|
||||
|
||||
@@ -197,6 +197,12 @@ describe("#searchForTeam", () => {
|
||||
expect(results.length).toBe(0);
|
||||
});
|
||||
|
||||
test("should handle backslashes in search term", async () => {
|
||||
const team = await buildTeam();
|
||||
const { results } = await Document.searchForTeam(team, "\\\\");
|
||||
expect(results.length).toBe(0);
|
||||
});
|
||||
|
||||
test("should return the total count of search results", async () => {
|
||||
const team = await buildTeam();
|
||||
const collection = await buildCollection({ teamId: team.id });
|
||||
|
||||
Reference in New Issue
Block a user