diff --git a/modules/reitit-frontend/src/reitit/frontend/history.cljs b/modules/reitit-frontend/src/reitit/frontend/history.cljs index 77db3406..0ef39c2e 100644 --- a/modules/reitit-frontend/src/reitit/frontend/history.cljs +++ b/modules/reitit-frontend/src/reitit/frontend/history.cljs @@ -22,10 +22,11 @@ (count (.getPathPrefix history))))) (defn- token->href [history token] - (str (if (.-useFragment_ history) - (str "#")) - (.getPathPrefix history) - token)) + (if token + (str (if (.-useFragment_ history) + (str "#")) + (.getPathPrefix history) + token))) (def ^:private current-domain (.getDomain (.parse Uri js/location))) @@ -110,7 +111,10 @@ token (match->token history match k params query)] (token->href history token)))) -(defn replace-token [{:keys [router history]} k params] - (let [match (rf/match-by-name router k params) - token (match->token history match k params query)] - (.replaceToken history token))) +(defn replace-token + ([state k params] + (replace-token state k params nil)) + ([{:keys [router history]} k params query] + (let [match (rf/match-by-name router k params) + token (match->token history match k params query)] + (.replaceToken history token)))) diff --git a/modules/reitit/project.clj b/modules/reitit/project.clj index 1bca731f..2915ef89 100644 --- a/modules/reitit/project.clj +++ b/modules/reitit/project.clj @@ -12,5 +12,4 @@ [metosin/reitit-schema] [metosin/reitit-swagger] [metosin/reitit-swagger-ui] - [metosin/reitit-frontend] - [metosin/reitit-re-frame]]) + [metosin/reitit-frontend]]) diff --git a/test/cljs/reitit/frontend/history_test.cljs b/test/cljs/reitit/frontend/history_test.cljs index 6652f321..4c09dcf1 100644 --- a/test/cljs/reitit/frontend/history_test.cljs +++ b/test/cljs/reitit/frontend/history_test.cljs @@ -19,7 +19,9 @@ (is (= "#/bar/5" (rfh/href history ::bar {:id 5}))) (is (= "#/bar/5?q=x" - (rfh/href history ::bar {:id 5} {:q "x"})))))) + (rfh/href history ::bar {:id 5} {:q "x"}))) + (is (= nil + (rfh/href history ::asd)))))) (deftest html5-history-test (let [router (r/router ["/" @@ -37,4 +39,6 @@ (is (= "/bar/5" (rfh/href history ::bar {:id 5}))) (is (= "/bar/5?q=x" - (rfh/href history ::bar {:id 5} {:q "x"})))))) + (rfh/href history ::bar {:id 5} {:q "x"}))) + (is (= nil + (rfh/href history ::asd))))))