Skip to content

Commit 33f3119

Browse files
authored
Merge pull request #2 from magnars/preserve-fragments-in-urls
Preserve fragments in URLs
2 parents 2fc311b + f7e7d13 commit 33f3119

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/pushy/core.cljs

+8-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
(defn- set-retrieve-token! [t]
2121
(set! (.. t -retrieveToken)
2222
(fn [path-prefix location]
23-
(str (.-pathname location) (.-search location))))
23+
(str (.-pathname location)
24+
(.-search location)
25+
(.-hash location))))
2426
t)
2527

2628
(defn- set-create-url! [t]
@@ -50,9 +52,11 @@
5052

5153
(defn- get-token-from-uri [uri]
5254
(let [path (.getPath uri)
53-
query (.getQuery uri)]
54-
;; Include query string in token
55-
(if (empty? query) path (str path "?" query))))
55+
query (.getQuery uri)
56+
fragment (.getFragment uri)]
57+
(cond-> path
58+
(seq query) (str "?" query)
59+
(seq fragment) (str "#" fragment))))
5660

5761
(defn pushy
5862
"Takes in three functions:

0 commit comments

Comments
 (0)