fix: strip leading and trailing whitespace from QR Code data
All leading and trailing whitespace is now removed from strings derived from QR codes, both in the case of `get-qr-code-data` (real camera) and `qr-test-view` (mock camera). Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
parent
c94977c8d3
commit
0a9919c991
|
@ -1,6 +1,7 @@
|
|||
(ns status-im.ui.components.camera
|
||||
(:require [goog.object :as object]
|
||||
[reagent.core :as reagent]
|
||||
[clojure.string :as string]
|
||||
[clojure.walk :as walk]
|
||||
[status-im.react-native.js-dependencies :as js-dependencies]
|
||||
[status-im.utils.platform :as platform]))
|
||||
|
@ -34,4 +35,5 @@
|
|||
(reagent/create-element default-camera (clj->js (merge {:inverted true} props))))
|
||||
|
||||
(defn get-qr-code-data [code]
|
||||
(.-data code))
|
||||
(when-let [data (.-data code)]
|
||||
(string/trim data)))
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
(ns status-im.ui.screens.qr-scanner.views
|
||||
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[clojure.string :as string]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.ui.components.camera :as camera]
|
||||
[status-im.ui.components.react :as react]
|
||||
|
@ -42,7 +43,7 @@
|
|||
:on-press #(re-frame/dispatch [:qr-scanner.callback/scan-qr-code-cancel opts])}]
|
||||
[button/button
|
||||
{:label "OK"
|
||||
:on-press #(re-frame/dispatch [:qr-scanner.callback/scan-qr-code-success opts @text-value])}]]]]))
|
||||
:on-press #(re-frame/dispatch [:qr-scanner.callback/scan-qr-code-success opts (when-let [text @text-value] (string/trim text))])}]]]]))
|
||||
|
||||
(defn corner [border1 border2 corner]
|
||||
[react/view (assoc {:border-color colors/white-persist :width 60 :height 60} border1 5 border2 5 corner 32)])
|
||||
|
|
Loading…
Reference in New Issue