From b4835a7860f85d8926fe535c4786415e03ca7d3a Mon Sep 17 00:00:00 2001 From: Tommi Reiman Date: Wed, 21 Mar 2018 08:15:28 +0200 Subject: [PATCH] Polish code --- doc/basics/name_based_routing.md | 2 +- modules/reitit-core/src/reitit/impl.cljc | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/basics/name_based_routing.md b/doc/basics/name_based_routing.md index f428e6a4..3e5c7d8c 100644 --- a/doc/basics/name_based_routing.md +++ b/doc/basics/name_based_routing.md @@ -64,7 +64,7 @@ With provided path-parameters: ; :path-params {:id "1"}} ``` -Path-parameters are automatically coerced into strings, with the help of (currently internal) Protocol `reitit.impl/IntoString`. It supports numbers, booleans, keywords and objects: +Path-parameters are automatically coerced into strings, with the help of (currently internal) Protocol `reitit.impl/IntoString`. It supports strings, numbers, booleans, keywords and objects: ```clj (r/match-by-name router ::user {:id 1}) diff --git a/modules/reitit-core/src/reitit/impl.cljc b/modules/reitit-core/src/reitit/impl.cljc index a012488f..9df30456 100644 --- a/modules/reitit-core/src/reitit/impl.cljc +++ b/modules/reitit-core/src/reitit/impl.cljc @@ -169,8 +169,8 @@ (.replace "+" "%20"))) (defn url-decode [s] - #?(:clj (some-> s (URLDecoder/decode "UTF-8")) - :cljs (some-> s (js/decodeURIComponent)))) + (some-> s #?(:clj (URLDecoder/decode "UTF-8") + :cljs (js/decodeURIComponent)))) (defprotocol IntoString (into-string [_])) @@ -183,9 +183,8 @@ #?(:clj clojure.lang.Keyword :cljs cljs.core.Keyword) (into-string [this] - (str (namespace this) - (when (namespace this) "/") - (name this))) + (let [ns (namespace this)] + (str ns (if ns "/") (name this)))) #?(:clj Boolean :cljs boolean)