Merge branch '19051-handle-quotes-in-search' into main
[arvados-workbench2.git] / src / services / api / filter-builder.ts
index 4809e7a80c83071b0d5889ce8a81b7b661bc4f83..da67935a1e5d8a44c5bf2c601c3fc639204ca8ab 100644 (file)
@@ -65,7 +65,18 @@ export class FilterBuilder {
     }
 
     public addFullTextSearch(value: string) {
-        const terms = value.trim().split(/(\s+)/);
+        const regex = /"[^"]*"/;
+        const matches: any[] = [];
+
+        let match = value.match(regex);
+
+        while (match) {
+            value = value.replace(match[0], "");
+            matches.push(match[0].replace(/"/g, ''));
+            match = value.match(regex);
+        }
+
+        const terms = value.trim().split(/(\s+)/).concat(matches);
         terms.forEach(term => {
             if (term !== " ") {
                 this.addCondition("any", "ilike", term, "%", "%");