diff --git a/modules/reitit-frontend/src/reitit/frontend.cljs b/modules/reitit-frontend/src/reitit/frontend.cljs index dd29697a5..089f4eb6d 100644 --- a/modules/reitit-frontend/src/reitit/frontend.cljs +++ b/modules/reitit-frontend/src/reitit/frontend.cljs @@ -21,9 +21,10 @@ (let [uri (.parse Uri path)] (if-let [match (reitit/match-by-path router (.getPath uri))] (let [q (query-params uri) + match (assoc match :query-params q) ;; Return uncoerced values if coercion is not enabled - so ;; that tha parameters are always accessible from same property. - parameters (or (coercion/coerce! (assoc match :query-params q)) + parameters (or (coercion/coerce! match) {:path (:path-params match) :query q})] (assoc match :parameters parameters))))) diff --git a/test/cljs/reitit/frontend/core_test.cljs b/test/cljs/reitit/frontend/core_test.cljs index 035863091..200090883 100644 --- a/test/cljs/reitit/frontend/core_test.cljs +++ b/test/cljs/reitit/frontend/core_test.cljs @@ -20,6 +20,7 @@ {:template "/" :data {:name ::frontpage} :path-params {} + :query-params {} :path "/" :parameters {:query {} :path {}}}) @@ -32,6 +33,7 @@ {:template "/foo" :data {:name ::foo} :path-params {} + :query-params {} :path "/foo" :parameters {:query {} :path {}}}) @@ -59,6 +61,7 @@ (is (= (r/map->Match {:template "/:id" :path-params {:id "5"} + :query-params {} :path "/5" :parameters {:query {} :path {:id 5}}}) @@ -71,7 +74,7 @@ (is (= (r/map->Match {:template "/:id" :path-params {:id "5"} - ;; Note: query not included in path + :query-params {:mode "foo"} :path "/5" :parameters {:path {:id 5} :query {:mode :foo}}}) @@ -84,6 +87,7 @@ (is (= (r/map->Match {:template "/:id" :path-params {:id "5"} + :query-params {:mode "foo"} :path "/5" :parameters {:path {:id 5} :query {:mode :foo}}})