diff --git a/examples/frontend-links/src/frontend/core.cljs b/examples/frontend-links/src/frontend/core.cljs index 03e82520..cc84dcf3 100644 --- a/examples/frontend-links/src/frontend/core.cljs +++ b/examples/frontend-links/src/frontend/core.cljs @@ -75,8 +75,8 @@ (rfe/href to path-params query-params) (let [match (rf/match-by-path router to) route (-> match :data :name) - params (not-empty (or path-params (:path-params match))) - query (not-empty (or query-params (:query-params match)))] + params (or path-params (:path-params match)) + query (or query-params (:query-params match))] (if match (rfe/href route params query) to)))) diff --git a/modules/reitit-core/src/reitit/core.cljc b/modules/reitit-core/src/reitit/core.cljc index 2f33c605..573ba5b2 100644 --- a/modules/reitit-core/src/reitit/core.cljc +++ b/modules/reitit-core/src/reitit/core.cljc @@ -67,7 +67,7 @@ ([match] (match->path match nil)) ([match query-params] - (some-> match :path (cond-> query-params (str "?" (impl/query-string query-params)))))) + (some-> match :path (cond-> (seq query-params) (str "?" (impl/query-string query-params)))))) ;; ;; Different routers diff --git a/test/cljc/reitit/core_test.cljc b/test/cljc/reitit/core_test.cljc index c48f6348..4d9ee770 100644 --- a/test/cljc/reitit/core_test.cljc +++ b/test/cljc/reitit/core_test.cljc @@ -354,6 +354,10 @@ (-> router (r/match-by-name! ::route {:a "olipa", :b "kerran"}) (r/match->path)))) + (is (= "/olipa/kerran" + (-> router + (r/match-by-name! ::route {:a "olipa", :b "kerran"}) + (r/match->path {})))) (is (= "/olipa/kerran?iso=p%C3%B6ril%C3%A4inen" (-> router (r/match-by-name! ::route {:a "olipa", :b "kerran"})