Commit 9406f6db authored by Ricardo J. Mendez's avatar Ricardo J. Mendez

Utils additions to parse user-entered ignore domains

parent a61a15f8
......@@ -2,7 +2,8 @@
(:require [cljs.core.async :refer [<!]]
[clojure.string :refer [lower-case trim]]
[dommy.core :as dommy]
[cognitect.transit :as transit])
[cognitect.transit :as transit]
[clojure.string :as string])
(:require-macros [cljs.core.async.macros :refer [go go-loop]]))
......@@ -82,6 +83,15 @@
(hash-string shortened))
0))
(defn to-string-set
"Split a string into a string set using commas, semi-colons or new lines, and returns it as a set"
[s]
(->>
(string/split (or s "") #",|\n|;")
(map string/trim)
(remove empty?)
(map string/lower-case)
(into #{})))
(defn time-display
"Returns a display string for a number of milliseconds"
......
......@@ -87,6 +87,7 @@
"chrome://extensions/?id=okhigbflgnbihoiokilagelkalkcigfp" "extensions"
"chrome-extension://okhigbflgnbihoiokilagelkalkcigfp/index.html" "okhigbflgnbihoiokilagelkalkcigfp"
"file:///Users/ricardo/Sources/user.html" ""
"view-source:http://localhost:4000/opensource/" ""
"" ""
nil nil
))
......@@ -115,7 +116,20 @@
"http://localhost" true
"https://numergent.com/" true
"chrome://extensions/?id=okhigbflgnbihoiokilagelkalkcigfp" false
"view-source:http://localhost:4000/opensource/" false
"http" false
"" false
nil false
))
\ No newline at end of file
))
(deftest test-to-string-set
(are [s result] (= result (utils/to-string-set s))
"alpha" #{"alpha"}
"alpha\nbeta" #{"alpha" "beta"}
"ALPHA\nBETA" #{"alpha" "beta"}
"alpha\nbeta " #{"alpha" "beta"}
"a\nbeta,c" #{"a" "beta" "c"}
"a\nbeta,C;d;" #{"a" "beta" "c" "d"}
"a,b,,c,;d;e;; f,e\n\n" #{"a" "b" "c" "d" "e" "f"}
))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment