From fdb6c7de751c5e842dd8efdb06f40faa004c5c7b Mon Sep 17 00:00:00 2001 From: "tales.kerschner" Date: Wed, 29 Oct 2025 20:27:16 -0300 Subject: [PATCH] Fix: make lower-casing nil-safe in common.cljc (avoid .toLowerCase on null) - aloof-sort-by: handle nils and non-strings before lower-casing - ->kebab-case: guard for strings and use clojure.string/lower-case Prevents TypeError: "toLowerCase" of null in cljs paths. --- src/cljc/orcpub/common.cljc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/cljc/orcpub/common.cljc b/src/cljc/orcpub/common.cljc index 3660c72ef..16192ec04 100644 --- a/src/cljc/orcpub/common.cljc +++ b/src/cljc/orcpub/common.cljc @@ -179,11 +179,18 @@ ;; Case Insensitive `sort-by` (defn aloof-sort-by [sorter coll] - (sort-by (comp s/lower-case sorter) coll) + (sort-by (fn [x] + (let [v (sorter x)] + (cond + (string? v) (s/lower-case v) + (nil? v) "" + :else (s/lower-case (str v))))) + coll) ) (defn ->kebab-case [s] - (-> s - ;; Insert hyphen before each capital letter, but not at the start. - (s/replace #"([A-Z])" "-$1") - .toLowerCase)) + (when (string? s) + (-> s + ;; Insert hyphen before each capital letter, but not at the start. + (s/replace #"([A-Z])" "-$1") + (s/lower-case))))