mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
🐛 Add missing string? guard to num-string? on JVM
The CLJS branch of num-string? checked (string? v) first, but the JVM branch did not. Passing non-string values (nil, keywords, etc.) would rely on exception handling inside parse-double for control flow. Add the string? check for consistency and to avoid using exceptions for normal control flow.
This commit is contained in:
parent
bba3610b7b
commit
95d4d42c91
@ -782,7 +782,8 @@
|
||||
(not (js/isNaN v))
|
||||
(not (js/isNaN (parse-double v))))
|
||||
|
||||
:clj (not= (parse-double v :nan) :nan)))
|
||||
:clj (and (string? v)
|
||||
(not= (parse-double v :nan) :nan))))
|
||||
|
||||
(defn read-string
|
||||
[v]
|
||||
|
||||
@ -841,6 +841,9 @@
|
||||
(t/is (d/num-string? "-7"))
|
||||
(t/is (not (d/num-string? "hello")))
|
||||
(t/is (not (d/num-string? nil)))
|
||||
;; non-string types always return false
|
||||
(t/is (not (d/num-string? 42)))
|
||||
(t/is (not (d/num-string? :keyword)))
|
||||
;; In CLJS, js/isNaN("") → false (empty string coerces to 0), so "" is numeric
|
||||
#?(:clj (t/is (not (d/num-string? ""))))
|
||||
#?(:cljs (t/is (d/num-string? ""))))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user