mirror of
https://github.com/metosin/reitit.git
synced 2025-12-17 00:11:11 +00:00
Add arities 1 and 2 to rf/match->path
To adhere to the docstring's info about parameter 2 and 3 being optional
This commit is contained in:
parent
4e85cb14c5
commit
2f3fc21c84
2 changed files with 10 additions and 4 deletions
|
|
@ -42,10 +42,14 @@
|
|||
match->path
|
||||
"Create routing path from given match and optional query-string map and
|
||||
optional fragment string."
|
||||
[match query-params fragment]
|
||||
(when-let [path (r/match->path match query-params)]
|
||||
(cond-> path
|
||||
(and fragment (seq fragment)) (str "#" (impl/form-encode fragment)))))
|
||||
([match]
|
||||
(match->path match nil nil))
|
||||
([match query-params]
|
||||
(match->path match query-params nil))
|
||||
([match query-params fragment]
|
||||
(when-let [path (r/match->path match query-params)]
|
||||
(cond-> path
|
||||
(and fragment (seq fragment)) (str "#" (impl/form-encode fragment))))))
|
||||
|
||||
(defn match-by-path
|
||||
"Given routing tree and current path, return match with possibly
|
||||
|
|
|
|||
|
|
@ -285,6 +285,8 @@
|
|||
|
||||
(deftest match->path-test
|
||||
(is (= "foo"
|
||||
(rf/match->path {:path "foo"})
|
||||
(rf/match->path {:path "foo"} nil)
|
||||
(rf/match->path {:path "foo"} nil nil)
|
||||
(rf/match->path {:path "foo"} {} "")))
|
||||
(is (= "foo?a=1&b=&c=foo+bar"
|
||||
|
|
|
|||
Loading…
Reference in a new issue