fix: Search query backslash replacement only touched first instance

closes #2111
This commit is contained in:
Tom Moor committed 2021-05-12 20:27:14 -07:00
1 parent 9d03c89c02
commit 3bd56fff9e
2 files changed
+7 -1

No files matched your search

+1 -1
View File
@@ -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 (
+6
View File
@@ -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 });