Merge pull request #685 from PEZ/rf-match-to-path-optional-arities

Add arities 1 and 2 to rf/match->path
This commit is contained in:
Tommi Reiman 2024-06-21 12:05:23 +03:00 committed by GitHub
commit 411bf39c7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

View file

@ -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

View file

@ -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"