Fix empty fragment url

This commit is contained in:
Juho Teperi 2018-06-12 15:44:37 +03:00
parent 50faacab25
commit 61a9871ebb
2 changed files with 10 additions and 10 deletions

View file

@ -28,17 +28,13 @@
(def routes (def routes
(rc/router (rc/router
["" ["/"
["" [""
{:name ::frontpage-root {:name ::frontpage
:view home-page}] :view home-page}]
["/" ["about"
["" {:name ::about
{:name ::frontpage :view about-page}]]))
:view home-page}]
["about"
{:name ::about
:view about-page}]]]))
(defn init! [] (defn init! []
(reset! router (rfh/start! routes (reset! router (rfh/start! routes

View file

@ -13,7 +13,11 @@
(defn- token->path [history token] (defn- token->path [history token]
(if (.-useFragment_ history) (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))) (str (.getPathPrefix history) token)))
(defn- path->token [history path] (defn- path->token [history path]