[Fix #3572] regx parse string bug in formatted texts
Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
parent
c8e88a74b4
commit
c3449a3a65
|
@ -103,7 +103,7 @@
|
||||||
(defn- parse-str-regx [string regx matched-fn unmatched-fn]
|
(defn- parse-str-regx [string regx matched-fn unmatched-fn]
|
||||||
(if (string? string)
|
(if (string? string)
|
||||||
(let [unmatched-text (as-> (->> (string/split string regx)
|
(let [unmatched-text (as-> (->> (string/split string regx)
|
||||||
(remove empty?)
|
(remove nil?)
|
||||||
vec) $
|
vec) $
|
||||||
(if (zero? (count $))
|
(if (zero? (count $))
|
||||||
[nil]
|
[nil]
|
||||||
|
|
|
@ -3,13 +3,16 @@
|
||||||
[status-im.chat.views.message.message :as message]))
|
[status-im.chat.views.message.message :as message]))
|
||||||
|
|
||||||
(deftest parse-url
|
(deftest parse-url
|
||||||
(is (= (lazy-seq [nil {:text "www.google.com" :url? true}])
|
(is (= (lazy-seq [{:text "" :url? false}
|
||||||
|
{:text "www.google.com" :url? true}])
|
||||||
(message/parse-url "www.google.com")))
|
(message/parse-url "www.google.com")))
|
||||||
(is (= (lazy-seq [nil {:text "status.im" :url? true}])
|
(is (= (lazy-seq [{:text "" :url? false}
|
||||||
|
{:text "status.im" :url? true}])
|
||||||
(message/parse-url "status.im")))
|
(message/parse-url "status.im")))
|
||||||
(is (= (lazy-seq [{:text "$33.90" :url? false} nil])
|
(is (= (lazy-seq [{:text "$33.90" :url? false} nil])
|
||||||
(message/parse-url "$33.90")))
|
(message/parse-url "$33.90")))
|
||||||
(is (= (lazy-seq [nil {:text "https://www.google.com/?gfe_rd=cr&dcr=0&ei=P9-CWuyBGaro8AeqkYGQDQ&gws_rd=cr&fg=1" :url? true}])
|
(is (= (lazy-seq [{:text "" :url? false}
|
||||||
|
{:text "https://www.google.com/?gfe_rd=cr&dcr=0&ei=P9-CWuyBGaro8AeqkYGQDQ&gws_rd=cr&fg=1" :url? true}])
|
||||||
(message/parse-url "https://www.google.com/?gfe_rd=cr&dcr=0&ei=P9-CWuyBGaro8AeqkYGQDQ&gws_rd=cr&fg=1")))
|
(message/parse-url "https://www.google.com/?gfe_rd=cr&dcr=0&ei=P9-CWuyBGaro8AeqkYGQDQ&gws_rd=cr&fg=1")))
|
||||||
(is (= (lazy-seq [{:text "Status - " :url? false}
|
(is (= (lazy-seq [{:text "Status - " :url? false}
|
||||||
{:text "https://github.com/status-im/status-react" :url? true}
|
{:text "https://github.com/status-im/status-react" :url? true}
|
||||||
|
|
Loading…
Reference in New Issue