Skip to content

Commit

Permalink
Merge pull request #2 from magnars/preserve-fragments-in-urls
Browse files Browse the repository at this point in the history
Preserve fragments in URLs
  • Loading branch information
shen-tian authored Nov 20, 2018
2 parents 2fc311b + f7e7d13 commit 33f3119
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/pushy/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
(defn- set-retrieve-token! [t]
(set! (.. t -retrieveToken)
(fn [path-prefix location]
(str (.-pathname location) (.-search location))))
(str (.-pathname location)
(.-search location)
(.-hash location))))
t)

(defn- set-create-url! [t]
Expand Down Expand Up @@ -50,9 +52,11 @@

(defn- get-token-from-uri [uri]
(let [path (.getPath uri)
query (.getQuery uri)]
;; Include query string in token
(if (empty? query) path (str path "?" query))))
query (.getQuery uri)
fragment (.getFragment uri)]
(cond-> path
(seq query) (str "?" query)
(seq fragment) (str "#" fragment))))

(defn pushy
"Takes in three functions:
Expand Down

0 comments on commit 33f3119

Please sign in to comment.