clean up
This commit is contained in:
parent
d430d62c26
commit
eb2b10571d
4 changed files with 44 additions and 44 deletions
17
src/computersandblues/lodestone/match.cljs
Normal file
17
src/computersandblues/lodestone/match.cljs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
(ns computersandblues.lodestone.match
|
||||
(:require [applied-science.js-interop :as j]))
|
||||
|
||||
(defn ->regex [s]
|
||||
(try
|
||||
(js/RegExp. s "i")
|
||||
(catch js/Error _
|
||||
(js/RegExp. (js/RegExp.escape s) "i"))))
|
||||
|
||||
(defn query->matching-fn [query]
|
||||
(let [match? (if query
|
||||
(partial re-find (->regex query))
|
||||
(constantly true))]
|
||||
(fn [post]
|
||||
(or (match? (j/get post :content))
|
||||
(match? (j/get-in post [:account :acct])) ; search for url + username of poster
|
||||
(some #(match? (j/get % :username)) (j/get post :mentions))))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue