mirror of
https://github.com/metosin/reitit.git
synced 2025-12-18 00:41:12 +00:00
Fix empty query params map resulting in redundant '?' in path
This commit is contained in:
parent
0919b46236
commit
f7332d3bc4
3 changed files with 7 additions and 3 deletions
|
|
@ -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))))
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"})
|
||||
|
|
|
|||
Loading…
Reference in a new issue