clj-commons / secretary

A client-side router for ClojureScript.
773 stars 64 forks source link

No params when route is matched after user presses the "back" button #90

Closed mjg123 closed 7 years ago

mjg123 commented 7 years ago

Not sure if this is a secretary bug or me misunderstanding how the browser is supposed to work.

I have 2 routes:

(defroute "/a" {:as m}  (.log js/console m) (show-page-a))
(defroute "/b" {:as m}  (show-page-b))

If I load a route like /a?foo=bar I see those params logged as expected, if I follow a link to /b then press back button, I get an empty map logged even though the url is still /a?foo=bar.

I'm using accountant to call dispatch! when following links, so there isn't a full page reload at that point.

mjg123 commented 7 years ago

This is my current workaround:

(defn current-url-params []
  (->> (.-location js/window)
       cemerick.url/url
       :query
       (map (fn [[k v]] [(keyword k) v]))
       (into {})))
mjg123 commented 7 years ago

Sorry - this was actually an accountant bug: https://github.com/venantius/accountant/pull/30