Skip to content
Browse files

Route bindings support string parameters names

  • Loading branch information...
1 parent 1fac7c2 commit 1d6d3910d0ba48630b4d91dce8d53b85d9b2d7c7 @weavejester committed
Showing with 14 additions and 2 deletions.
  1. +5 −2 src/compojure/core.clj
  2. +9 −0 test/compojure/test/core.clj
View
7 src/compojure/core.clj
@@ -36,10 +36,13 @@
(merge-with merge request {:route-params params, :params params}))
(defn- assoc-&-binding [binds req sym]
- (assoc binds sym `(dissoc (:params ~req) ~@(map keyword (keys binds)))))
+ (assoc binds sym `(dissoc (:params ~req)
+ ~@(map keyword (keys binds))
+ ~@(map str (keys binds)))))
(defn- assoc-symbol-binding [binds req sym]
- (assoc binds sym `(get-in ~req [:params ~(keyword sym)])))
+ (assoc binds sym `(get-in ~req [:params ~(keyword sym)]
+ (get-in ~req [:params ~(str sym)]))))
(defn- vector-bindings
"Create the bindings for a vector of parameters."
View
9 test/compojure/test/core.clj
@@ -26,6 +26,15 @@
(-> (request :get "/foo")
(assoc :params {:y "bar", :z "baz"}))))
+ (testing "string parameter names"
+ ((GET "/:x" [x y & more]
+ (is (= x "foo"))
+ (is (= y "bar"))
+ (is (= more {"z" "baz"}))
+ nil)
+ (-> (request :get "/foo")
+ (assoc :params {"y" "bar", "z" "baz"}))))
+
(testing "vector ':as request' arguments"
(let [req (-> (request :get "/foo")
(assoc :params {:y "bar"}))]

0 comments on commit 1d6d391

Please sign in to comment.
Something went wrong with that request. Please try again.