From 61a9871ebbf8fb40fd57d42b03201b9bc1100629 Mon Sep 17 00:00:00 2001 From: Juho Teperi Date: Tue, 12 Jun 2018 15:44:37 +0300 Subject: [PATCH] Fix empty fragment url --- examples/frontend/src/frontend/core.cljs | 14 +++++--------- .../src/reitit/frontend/history.cljs | 6 +++++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/frontend/src/frontend/core.cljs b/examples/frontend/src/frontend/core.cljs index 4f4d9276..dee5c817 100644 --- a/examples/frontend/src/frontend/core.cljs +++ b/examples/frontend/src/frontend/core.cljs @@ -28,17 +28,13 @@ (def routes (rc/router - ["" + ["/" ["" - {:name ::frontpage-root + {:name ::frontpage :view home-page}] - ["/" - ["" - {:name ::frontpage - :view home-page}] - ["about" - {:name ::about - :view about-page}]]])) + ["about" + {:name ::about + :view about-page}]])) (defn init! [] (reset! router (rfh/start! routes diff --git a/modules/reitit-frontend/src/reitit/frontend/history.cljs b/modules/reitit-frontend/src/reitit/frontend/history.cljs index 0ef39c2e..e451d212 100644 --- a/modules/reitit-frontend/src/reitit/frontend/history.cljs +++ b/modules/reitit-frontend/src/reitit/frontend/history.cljs @@ -13,7 +13,11 @@ (defn- token->path [history token] (if (.-useFragment_ history) - token + ;; If no fragment at all, default to "/" + ;; If fragment is present, the token already is prefixed with "/" + (if (= "" token) + (.getPathPrefix history) + token) (str (.getPathPrefix history) token))) (defn- path->token [history path]