[Fix #3572] regx parse string bug in formatted texts

Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
Foo Pang 2018-03-15 17:47:32 +08:00 committed by Julien Eluard
parent c8e88a74b4
commit c3449a3a65
No known key found for this signature in database
GPG Key ID: 6FD7DB5437FCBEF6
2 changed files with 7 additions and 4 deletions

View File

@ -103,7 +103,7 @@
(defn- parse-str-regx [string regx matched-fn unmatched-fn]
(if (string? string)
(let [unmatched-text (as-> (->> (string/split string regx)
(remove empty?)
(remove nil?)
vec) $
(if (zero? (count $))
[nil]

View File

@ -3,13 +3,16 @@
[status-im.chat.views.message.message :as message]))
(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")))
(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")))
(is (= (lazy-seq [{:text "$33.90" :url? false} nil])
(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")))
(is (= (lazy-seq [{:text "Status - " :url? false}
{:text "https://github.com/status-im/status-react" :url? true}