diff --git a/dev-resources/public/with space.txt b/dev-resources/public/with space.txt
new file mode 100644
index 00000000..ce013625
--- /dev/null
+++ b/dev-resources/public/with space.txt
@@ -0,0 +1 @@
+hello
diff --git a/modules/reitit-ring/src/reitit/ring.cljc b/modules/reitit-ring/src/reitit/ring.cljc
index 0e513847..ab897c11 100644
--- a/modules/reitit-ring/src/reitit/ring.cljc
+++ b/modules/reitit-ring/src/reitit/ring.cljc
@@ -222,12 +222,12 @@
(recur files))))))
handler (if path
(fn [request]
- (let [uri (:uri request)]
+ (let [uri (impl/url-decode (:uri request))]
(if (str/starts-with? uri path)
(or (path-or-index-response (subs uri path-size) uri)
(not-found-handler request)))))
(fn [request]
- (let [uri (:uri request)
+ (let [uri (impl/url-decode (:uri request))
path (-> request :path-params parameter)]
(or (path-or-index-response path uri)
(not-found-handler request)))))]
diff --git a/test/cljc/reitit/ring_test.cljc b/test/cljc/reitit/ring_test.cljc
index 52dd938b..b057b401 100644
--- a/test/cljc/reitit/ring_test.cljc
+++ b/test/cljc/reitit/ring_test.cljc
@@ -471,9 +471,9 @@
(testing "from root"
(let [app (ring/ring-handler
- (ring/router
- ["/*" (create nil)])
- (ring/create-default-handler))]
+ (ring/router
+ ["/*" (create nil)])
+ (ring/create-default-handler))]
(testing "different file-types"
(let [response (app (request "/hello.json"))]
(is (= "application/json" (get-in response [:headers "Content-Type"])))
@@ -484,6 +484,11 @@
(is (get-in response [:headers "Last-Modified"]))
(is (= "file\n" (slurp (:body response))))))
+ (testing "with url decoding"
+ (let [response (app (request "/with%20space.txt"))]
+ (is (= 200 (:status response)))
+ (is (= "hello\n" (slurp (:body response))))))
+
(testing "index-files"
(let [response (app (request "/docs"))]
(is (= (redirect "/docs/index.html") response)))
@@ -520,6 +525,11 @@
(is (get-in response [:headers "Last-Modified"]))
(is (= "file\n" (slurp (:body response))))))
+ (testing "with url decoding"
+ (let [response (app (request "/with%20space.txt"))]
+ (is (= 200 (:status response)))
+ (is (= "hello\n" (slurp (:body response))))))
+
(testing "index-files"
(let [response (app (request "/docs"))]
(is (= (redirect "/docs/index.html") response)))
@@ -557,6 +567,11 @@
(is (get-in response [:headers "Last-Modified"]))
(is (= "file\n" (slurp (:body response))))))
+ (testing "with url decoding"
+ (let [response (app (request "/with%20space.txt"))]
+ (is (= 200 (:status response)))
+ (is (= "hello\n" (slurp (:body response))))))
+
(testing "index-files"
(let [response (app (request "/docs"))]
(is (= (redirect "/docs/index.html") response)))
@@ -595,6 +610,11 @@
(is (get-in response [:headers "Last-Modified"]))
(is (= "file\n" (slurp (:body response))))))
+ (testing "with url decoding"
+ (let [response (app (request "/with%20space.txt"))]
+ (is (= 200 (:status response)))
+ (is (= "hello\n" (slurp (:body response))))))
+
(testing "index-files"
(let [response (app (request "/docs"))]
(is (= (redirect "/docs/index.html") response)))