Better regex handling.
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
5447f43f6c
commit
c1b081dde8
|
|
@ -24,11 +24,16 @@
|
|||
[(get-else $ ?e :thumbnail :nil) ?thumbnail]
|
||||
[?e :relative-path ?path]]})
|
||||
|
||||
(defn escape-regex
|
||||
"Escape regex special characters so user input is matched literally."
|
||||
[text]
|
||||
(str/replace text #"[.*+?^${}()|\[\]\\]" #(str "\\" %)))
|
||||
|
||||
(defn db-search-filter
|
||||
"Add where clauses to the datalog query when supplied"
|
||||
[{:keys [search tag]}]
|
||||
(let [re-search (when-not (str/blank? search)
|
||||
(re-pattern (str "(?i)" search)))]
|
||||
(re-pattern (str "(?i)" (escape-regex search))))]
|
||||
(cond-> db-search
|
||||
(not (str/blank? tag))
|
||||
(update-in [:where] #(conj % ['?e :tags tag]))
|
||||
|
|
|
|||
Loading…
Reference in New Issue