Skip to content

Commit

Permalink
Merge pull request #685 from PEZ/rf-match-to-path-optional-arities
Browse files Browse the repository at this point in the history
Add arities 1 and 2 to rf/match->path
  • Loading branch information
ikitommi committed Jun 21, 2024
2 parents 4e85cb1 + 2f3fc21 commit 411bf39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 8 additions & 4 deletions modules/reitit-frontend/src/reitit/frontend.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test/cljs/reitit/frontend/core_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 411bf39

Please sign in to comment.