Skip to content

Commit dc651cd

Browse files
committed
Click event sets token with query string
1 parent d764e79 commit dc651cd

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

project.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject kibu/pushy "0.3.1"
1+
(defproject kibu/pushy "0.3.2"
22
:description "HTML5 pushState for Clojurescript"
33
:url "https://github.com/kibu-australia/pushy"
44
:license {:name "Eclipse Public License"

src/pushy/core.cljs

+8-5
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,15 @@
9090
(on-click
9191
(fn [e]
9292
(when-let [el (recur-href (-> e .-target))]
93-
(let [href (.-href el)
94-
path (->> href (.parse Uri) .getPath)]
93+
(let [uri (.parse Uri (.-href el))
94+
path (.getPath uri)
95+
query (.getQuery uri)
96+
;; Include query string in token
97+
next-token (if (empty? query) path (str path "?" query))]
9598
;; Proceed if `identity-fn` returns a value and
9699
;; the user did not trigger the event via one of the
97100
;; keys we should bypass
98-
(when (and (identity-fn (match-fn path))
101+
(when (and (identity-fn (match-fn next-token))
99102
;; Bypass dispatch if any of these keys
100103
(not (.-altKey e))
101104
(not (.-ctrlKey e))
@@ -107,8 +110,8 @@
107110
(not= 1 (.-button e)))
108111
;; Dispatch!
109112
(if-let [title (-> el .-title)]
110-
(set-token! this path title)
111-
(set-token! this path))
113+
(set-token! this next-token title)
114+
(set-token! this next-token))
112115
(.preventDefault e)))))))
113116
nil)
114117

0 commit comments

Comments
 (0)