Add note about not encoding paths to docs

This commit is contained in:
Matthew Davidson 2018-09-05 19:38:31 -04:00
parent d8ca699443
commit 656b01752a
3 changed files with 6 additions and 18 deletions

View file

@ -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`.

View file

@ -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

View file

@ -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 [_]))