From 3342e775384973e3c6fe32738301b021cb0310e8 Mon Sep 17 00:00:00 2001 From: Loukas Agorgianitis Date: Fri, 28 Mar 2025 13:57:15 +0200 Subject: [PATCH] Change default index-redirect? value to false Signed-off-by: Loukas Agorgianitis --- modules/reitit-ring/src/reitit/ring.cljc | 2 +- test/clj/reitit/http_test.clj | 16 ++++++++-------- test/cljc/reitit/openapi_test.clj | 2 +- test/cljc/reitit/ring_test.cljc | 20 ++++++++++---------- test/cljc/reitit/swagger_test.clj | 2 +- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/modules/reitit-ring/src/reitit/ring.cljc b/modules/reitit-ring/src/reitit/ring.cljc index 15e953a8..5ff266bd 100644 --- a/modules/reitit-ring/src/reitit/ring.cljc +++ b/modules/reitit-ring/src/reitit/ring.cljc @@ -231,7 +231,7 @@ :or {parameter (keyword "") root "public" index-files ["index.html"] - index-redirect? true + index-redirect? false canonicalize-uris? true paths (constantly nil)}}] (let [options {:root root diff --git a/test/clj/reitit/http_test.clj b/test/clj/reitit/http_test.clj index c373a7af..1f04f72c 100644 --- a/test/clj/reitit/http_test.clj +++ b/test/clj/reitit/http_test.clj @@ -386,9 +386,9 @@ (testing "index-files" (let [response (app (request "/docs"))] - (is (= (redirect "/docs/index.html") response))) + (is (= (redirect "/docs/") response))) (let [response (app (request "/docs/"))] - (is (= (redirect "/docs/index.html") response)))) + (is (= 200 (:status response))))) (testing "not found" (let [response (app (request "/not-found"))] @@ -424,9 +424,9 @@ (testing "index-files" (let [response (app (request "/docs"))] - (is (= (redirect "/docs/index.html") response))) + (is (= (redirect "/docs/") response))) (let [response (app (request "/docs/"))] - (is (= (redirect "/docs/index.html") response)))) + (is (= 200 (:status response))))) (testing "not found" (let [response (app (request "/not-found"))] @@ -463,9 +463,9 @@ (testing "index-files" (let [response (app (request "/docs"))] - (is (= (redirect "/docs/index.html") response))) + (is (= (redirect "/docs/") response))) (let [response (app (request "/docs/"))] - (is (= (redirect "/docs/index.html") response)))) + (is (= 200 (:status response))))) (testing "not found" (let [response (app (request "/not-found"))] @@ -502,9 +502,9 @@ (testing "index-files" (let [response (app (request "/docs"))] - (is (= (redirect "/docs/index.html") response))) + (is (= (redirect "/docs/") response))) (let [response (app (request "/docs/"))] - (is (= (redirect "/docs/index.html") response)))) + (is (= 200 (:status response))))) (testing "not found" (let [response (app (request "/not-found"))] diff --git a/test/cljc/reitit/openapi_test.clj b/test/cljc/reitit/openapi_test.clj index 1b61f428..c474fbf3 100644 --- a/test/cljc/reitit/openapi_test.clj +++ b/test/cljc/reitit/openapi_test.clj @@ -337,7 +337,7 @@ {:path "/" :url "/openapi.json" :config {:jsonEditor true}})] - (is (= 302 (:status (app {:request-method :get, :uri "/"})))) + (is (= 200 (:status (app {:request-method :get, :uri "/"})))) (is (= 200 (:status (app {:request-method :get, :uri "/index.html"})))) (is (= {:jsonEditor true, :url "/openapi.json"} (->> {:request-method :get, :uri "/config.json"} diff --git a/test/cljc/reitit/ring_test.cljc b/test/cljc/reitit/ring_test.cljc index 45645f8b..27d3aa58 100644 --- a/test/cljc/reitit/ring_test.cljc +++ b/test/cljc/reitit/ring_test.cljc @@ -526,9 +526,9 @@ (testing "index-files" (let [response (app (request "/docs"))] - (is (= (redirect "/docs/index.html") response))) + (is (= (redirect "/docs/") response))) (let [response (app (request "/docs/"))] - (is (= (redirect "/docs/index.html") response)))) + (is (= 200 (:status response))))) (testing "not found" (let [response (app (request "/not-found"))] @@ -567,9 +567,9 @@ (testing "index-files" (let [response (app (request "/docs"))] - (is (= (redirect "/docs/index.html") response))) + (is (= (redirect "/docs/") response))) (let [response (app (request "/docs/"))] - (is (= (redirect "/docs/index.html") response)))) + (is (= 200 (:status response))))) (testing "not found" (let [response (app (request "/not-found"))] @@ -609,9 +609,9 @@ (testing "index-files" (let [response (app (request "/docs"))] - (is (= (redirect "/docs/index.html") response))) + (is (= (redirect "/docs/") response))) (let [response (app (request "/docs/"))] - (is (= (redirect "/docs/index.html") response)))) + (is (= 200 (:status response))))) (testing "not found" (let [response (app (request "/not-found"))] @@ -652,9 +652,9 @@ (testing "index-files" (let [response (app (request "/docs"))] - (is (= (redirect "/docs/index.html") response))) + (is (= (redirect "/docs/") response))) (let [response (app (request "/docs/"))] - (is (= (redirect "/docs/index.html") response)))) + (is (= 200 (:status response))))) (testing "not found" (let [response (app {:uri "/not-found" :request-method :get})] @@ -707,12 +707,12 @@ (testing "index-files" (let [response (app (request "/docs"))] - (is (= (redirect "/docs/index.html") response))) + (is (= (redirect "/docs/") response))) (testing "not found if dir doesn't exist" (let [response (app (request "/foobar"))] (is (= 404 (:status response))))) (let [response (app (request "/docs/"))] - (is (= 302 (:status response)))) + (is (= 200 (:status response)))) (let [response (app (request "/docs/index.html"))] (is (= 200 (:status response))))))) diff --git a/test/cljc/reitit/swagger_test.clj b/test/cljc/reitit/swagger_test.clj index 7c215ed6..593a1287 100644 --- a/test/cljc/reitit/swagger_test.clj +++ b/test/cljc/reitit/swagger_test.clj @@ -392,7 +392,7 @@ (let [app (swagger-ui/create-swagger-ui-handler {:path "/" :config {:jsonEditor true}})] - (is (= 302 (:status (app {:request-method :get, :uri "/"})))) + (is (= 200 (:status (app {:request-method :get, :uri "/"})))) (is (= 200 (:status (app {:request-method :get, :uri "/index.html"})))) (is (= {:jsonEditor true, :url "/swagger.json"} (->> {:request-method :get, :uri "/config.json"}