Skip to content

Commit

Permalink
Revert formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
liamchzh committed May 10, 2022
1 parent f185750 commit 7295b9c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 10 additions & 8 deletions src/compojure/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@
(defn- context-request [request route context-path]
(if-let [params (clout/route-matches route request)]
(let [uri (:uri request)
path (:path-info request uri)
context (or (:context request) "")
subpath (:__path-info params)
params (dissoc params :__path-info)]
(-> request
Expand All @@ -274,17 +276,17 @@
(let [re-context {:__path-info #"|/.*"}]
(cond
(string? route)
(clout/route-compile (str route ":__path-info") re-context)
(clout/route-compile (str route ":__path-info") re-context)
(and (vector? route) (literal? route))
(clout/route-compile
(str (first route) ":__path-info")
(merge (apply hash-map (rest route)) re-context))
(clout/route-compile
(str (first route) ":__path-info")
(merge (apply hash-map (rest route)) re-context))
(vector? route)
`(clout/route-compile
(str ~(first route) ":__path-info")
~(merge (apply hash-map (rest route)) re-context))
`(clout/route-compile
(str ~(first route) ":__path-info")
~(merge (apply hash-map (rest route)) re-context))
:else
`(clout/route-compile (str ~route ":__path-info") ~re-context))))
`(clout/route-compile (str ~route ":__path-info") ~re-context))))

(defn ^:no-doc make-context [route path make-handler]
(letfn [(handler
Expand Down
4 changes: 2 additions & 2 deletions test/compojure/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
(let [handler (GET "/ip/:ip" [ip] ip)
cxt-handler (context "/ip/:ip" [ip] (GET "/" [] ip))
in-cxt-handler (context "/ip" [] (GET "/:ip" [ip] ip))
request (mock/request :get "/ip/0%3A0%3A0%3A0%3A0%3A0%3A0%3A1%250")]
request (mock/request :get "/ip/0%3A0%3A0%3A0%3A0%3A0%3A0%3A1%250") ]
(is (= (-> request handler :body) "0:0:0:0:0:0:0:1%0"))
(is (= (-> request cxt-handler :body) "0:0:0:0:0:0:0:1%0"))
(is (= (-> request in-cxt-handler :body) "0:0:0:0:0:0:0:1%0"))))
Expand All @@ -221,7 +221,7 @@
(let [handler (GET "/emote/:emote" [emote] emote)
cxt-handler (context "/emote/:emote" [emote] (GET "/" [] emote))
in-cxt-handler (context "/emote" [] (GET "/:emote" [emote] emote))
request (mock/request :get "/emote/%5C%3F%2F")]
request (mock/request :get "/emote/%5C%3F%2F") ]
(is (= (-> request handler :body) "\\?/"))
(is (= (-> request cxt-handler :body) "\\?/"))
(is (= (-> request in-cxt-handler :body) "\\?/"))))
Expand Down

0 comments on commit 7295b9c

Please sign in to comment.