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:
Peter Strömberg 2024-06-21 09:59:33 +02:00
parent 4e85cb14c5
commit 2f3fc21c84
2 changed files with 10 additions and 4 deletions

View file

@ -42,10 +42,14 @@
match->path match->path
"Create routing path from given match and optional query-string map and "Create routing path from given match and optional query-string map and
optional fragment string." optional fragment string."
[match query-params fragment] ([match]
(when-let [path (r/match->path match query-params)] (match->path match nil nil))
(cond-> path ([match query-params]
(and fragment (seq fragment)) (str "#" (impl/form-encode fragment))))) (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 (defn match-by-path
"Given routing tree and current path, return match with possibly "Given routing tree and current path, return match with possibly

View file

@ -285,6 +285,8 @@
(deftest match->path-test (deftest match->path-test
(is (= "foo" (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"} nil nil)
(rf/match->path {:path "foo"} {} ""))) (rf/match->path {:path "foo"} {} "")))
(is (= "foo?a=1&b=&c=foo+bar" (is (= "foo?a=1&b=&c=foo+bar"