Skip to content
Snippets Groups Projects
Unverified Commit a31ff2e5 authored by Chris Truter's avatar Chris Truter Committed by GitHub
Browse files

Fix search query issue with trailing quotation mark (#49933)

parent 03af173d
No related branches found
No related tags found
No related merge requests found
...@@ -179,6 +179,8 @@ ...@@ -179,6 +179,8 @@
(defn- process-phrase [word-or-phrase] (defn- process-phrase [word-or-phrase]
;; a phrase is quoted even if the closing quotation mark has not been typed yet ;; a phrase is quoted even if the closing quotation mark has not been typed yet
(cond (cond
;; trailing quotation mark
(= word-or-phrase "\"") nil
;; quoted phrases must be matched sequentially ;; quoted phrases must be matched sequentially
(str/starts-with? word-or-phrase "\"") (str/starts-with? word-or-phrase "\"")
(as-> word-or-phrase <> (as-> word-or-phrase <>
...@@ -206,6 +208,7 @@ ...@@ -206,6 +208,7 @@
(->> words-and-phrases (->> words-and-phrases
(remove #{"and"}) (remove #{"and"})
(map process-phrase) (map process-phrase)
(remove str/blank?)
(str/join " & "))) (str/join " & ")))
(defn- complete-last-word (defn- complete-last-word
......
...@@ -190,7 +190,9 @@ ...@@ -190,7 +190,9 @@
(testing "unbalanced quotes" (testing "unbalanced quotes"
(is (= "'big' <-> 'data' & 'big' <-> 'mistake':*" (is (= "'big' <-> 'data' & 'big' <-> 'mistake':*"
(search-expr "\"Big Data\" \"Big Mistake")))) (search-expr "\"Big Data\" \"Big Mistake")))
(is (= "'something'"
(search-expr "something \""))))
(is (= "'partial' <-> 'quoted' <-> 'and' <-> 'or' <-> '-split':*" (is (= "'partial' <-> 'quoted' <-> 'and' <-> 'or' <-> '-split':*"
(search-expr "\"partial quoted AND OR -split"))) (search-expr "\"partial quoted AND OR -split")))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment