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
(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

View file

@ -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]