From 2f3fc21c848acc8a41f0ebdfc1b738a6e370b81e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Fri, 21 Jun 2024 09:59:33 +0200 Subject: [PATCH] Add arities 1 and 2 to rf/match->path To adhere to the docstring's info about parameter 2 and 3 being optional --- modules/reitit-frontend/src/reitit/frontend.cljs | 12 ++++++++---- test/cljs/reitit/frontend/core_test.cljs | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/reitit-frontend/src/reitit/frontend.cljs b/modules/reitit-frontend/src/reitit/frontend.cljs index ba122802..331b8cbe 100644 --- a/modules/reitit-frontend/src/reitit/frontend.cljs +++ b/modules/reitit-frontend/src/reitit/frontend.cljs @@ -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 diff --git a/test/cljs/reitit/frontend/core_test.cljs b/test/cljs/reitit/frontend/core_test.cljs index 12d461fa..0d7a7bc7 100644 --- a/test/cljs/reitit/frontend/core_test.cljs +++ b/test/cljs/reitit/frontend/core_test.cljs @@ -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"