From 656b01752a5a876cfad58803bcbe241753f528a4 Mon Sep 17 00:00:00 2001 From: Matthew Davidson Date: Wed, 5 Sep 2018 19:38:31 -0400 Subject: [PATCH] Add note about not encoding paths to docs --- doc/basics/route_syntax.md | 5 +++++ modules/reitit-core/src/reitit/core.cljc | 14 +------------- modules/reitit-core/src/reitit/impl.cljc | 5 ----- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/doc/basics/route_syntax.md b/doc/basics/route_syntax.md index 0b84a7de..b96a8501 100644 --- a/doc/basics/route_syntax.md +++ b/doc/basics/route_syntax.md @@ -84,3 +84,8 @@ Routes are just data, so it's easy to create them programmatically: ; ["/add-user" {:post {:interceptors [add-user]}}] ; ["/add-order" {:post {:interceptors [add-order]}}])] ``` + +### Encoding + +Reitit does not apply any encoding to your paths. If you need that, you must encode them yourself. +E.g., `/foo bar` should be `/foo%20bar`. diff --git a/modules/reitit-core/src/reitit/core.cljc b/modules/reitit-core/src/reitit/core.cljc index 4ada0c6a..70a5680a 100644 --- a/modules/reitit-core/src/reitit/core.cljc +++ b/modules/reitit-core/src/reitit/core.cljc @@ -112,17 +112,6 @@ (defn find-names [routes _] (into [] (keep #(-> % second :name)) routes)) -(defn- encode-route - "URL-encode all non-parameter segments" - [[p m]] - (let [segments (str/split p #"/") - encoded-segments (map #(if (impl/wild-or-catch-all-param? %) % (impl/url-encode %)) segments) - encoded-path (str/join "/" encoded-segments)] - [encoded-path m])) - -(defn- encode-routes [routes] - (map encode-route routes)) - (defn- compile-route [[p m :as route] {:keys [compile] :as opts}] [p m (if compile (compile route opts))]) @@ -432,8 +421,7 @@ routes (resolve-routes raw-routes opts) path-conflicting (path-conflicting-routes routes) name-conflicting (name-conflicting-routes routes) - encoded-routes (encode-routes routes) - compiled-routes (compile-routes encoded-routes opts) + compiled-routes (compile-routes routes opts) wilds? (boolean (some impl/wild-route? compiled-routes)) all-wilds? (every? impl/wild-route? compiled-routes) router (cond diff --git a/modules/reitit-core/src/reitit/impl.cljc b/modules/reitit-core/src/reitit/impl.cljc index cacd6175..6f954807 100644 --- a/modules/reitit-core/src/reitit/impl.cljc +++ b/modules/reitit-core/src/reitit/impl.cljc @@ -219,11 +219,6 @@ [coll] (map-kv url-decode coll)) -(defn url-encode-coll - "URL-encodes maps and vectors" - [coll] - (map-kv url-encode coll)) - (defprotocol IntoString (into-string [_]))