Skip to content

Commit

Permalink
Preserve fragments in URLs
Browse files Browse the repository at this point in the history
When URLs have fragments in them, pushy used to discard them. This change
preserves the fragment. Example:

    <a href="/a-page#some-header">

Pushy would go to just "/a-page" before this change.
  • Loading branch information
magnars committed Mar 16, 2017
1 parent 923581d commit f7e7d13
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 @@ -27,7 +27,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 @@ -57,9 +59,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 f7e7d13

Please sign in to comment.