Skip to content

Commit d093486

Browse files
committed
Don't ignore coercions that return false
Fixes #150.
1 parent 46384c7 commit d093486

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/compojure/core.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
(if (vector? bindings)
112112
`(let [~@(vector-bindings bindings request)]
113113
~(if-let [syms (application-symbols bindings)]
114-
`(if (and ~@syms) (do ~@body))
114+
`(if (and ~@(for [s syms] `(not (nil? ~s)))) (do ~@body))
115115
`(do ~@body)))
116116
`(let [~bindings ~request] ~@body)))
117117

test/compojure/core_test.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
(mock/request :get "/foo/bar")))))
5757
(is (not (nil? ((GET "/foo/:x" [x :<< coercions/as-int] (str x))
5858
(mock/request :get "/foo/100")))))
59+
(is (not (nil? ((GET "/foo/:x" [x :<< #(Boolean/valueOf %)] (str x))
60+
(mock/request :get "/foo/false")))))
5961
(is (nil? ((GET "/foo/:x" [x :<< coercions/as-int] (str x))
6062
(mock/request :get "/foo/bar")))))
6163

0 commit comments

Comments
 (0)