From 2da94f733d6924d6c22327b908a40f29f721f2bb Mon Sep 17 00:00:00 2001 From: Tommi Reiman Date: Sat, 29 Jun 2024 16:21:28 +0300 Subject: [PATCH] don't merge records --- modules/reitit-core/src/reitit/impl.cljc | 2 +- test/cljc/reitit/ring_test.cljc | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/reitit-core/src/reitit/impl.cljc b/modules/reitit-core/src/reitit/impl.cljc index 9afd570a..70e36119 100644 --- a/modules/reitit-core/src/reitit/impl.cljc +++ b/modules/reitit-core/src/reitit/impl.cljc @@ -29,7 +29,7 @@ f (-match p' path-map)] (cond f (conj l [p' (f v)]) - (and (map? v) (seq v)) (-path-vals l p' v) + (and (map? v) (not (record? v)) (seq v)) (-path-vals l p' v) :else (conj l [p' v])))) l m))] (-path-vals [] [] m))) diff --git a/test/cljc/reitit/ring_test.cljc b/test/cljc/reitit/ring_test.cljc index e00b52d7..c38bb69e 100644 --- a/test/cljc/reitit/ring_test.cljc +++ b/test/cljc/reitit/ring_test.cljc @@ -760,3 +760,17 @@ (is (= (r "2") (app {:uri "/", :request-method :get}))) (def routes ["/" (constantly (r "3"))]) ;; redefine again (is (= (r "3") (app {:uri "/", :request-method :get})))))))) + +(defrecord FooTest [a b]) + +(deftest path-update-fix-686 + (testing "records are retained" + (is (= true (-> ["/api/foo" {:get {:handler (constantly {:status 200}) + :test (FooTest. 1 2)}}] + (ring/router) + (r/compiled-routes) + (first) + (second) + :get + :test + (record?))))))