diff --git a/src/clj_jwt/json_key_fn.clj b/src/clj_jwt/json_key_fn.clj index 471dd7c..c33cfbf 100644 --- a/src/clj_jwt/json_key_fn.clj +++ b/src/clj_jwt/json_key_fn.clj @@ -2,16 +2,13 @@ (:require [clojure.string :as str])) -(defn write-key - [x] - (cond - (string? x) (str "\"" x "\"") - :else (name x))) +(def write-key name) (defn read-key + "don't keywordize keys with / or ." [x] - (if-let [y (re-seq #"^\"(.*)\"$" x)] - (-> y first second) + (if (re-matches #".*[/.].*" x) + x (keyword x))) diff --git a/test/clj_jwt/json_key_fn_test.clj b/test/clj_jwt/json_key_fn_test.clj index 6c5832a..76857d6 100644 --- a/test/clj_jwt/json_key_fn_test.clj +++ b/test/clj_jwt/json_key_fn_test.clj @@ -5,8 +5,8 @@ (fact "write-key should work fine." (write-key :foo) => "foo" - (write-key "foo") => "\"foo\"") + (write-key "foo") => "foo") (fact "read-key should work fine." (read-key "foo") => :foo - (read-key "\"foo\"") => "foo") + (read-key "foo/bar") => "foo/bar")