clj-commons / secretary

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

Query params in named routes #63

Open ostronom opened 9 years ago

ostronom commented 9 years ago

Given this route definition:

(defroute exchange-link "/exchange" [z]
  (println "route params" z))

and this invokation:

(sec/dispatch! "/exchange?a=b")

I'm getting:

route params nil

instead of

route params {:query-params ... }
(defroute exchange-link "/exchange" {:keys [query-params]}
  (println "route params" query-params))

gives the same result.

noprompt commented 9 years ago

That seems interesting considering this is thoroughly tested. Some more context would be helpful (if this is still an issue).

julienfantin commented 9 years ago

The secretary readme describes a google closure history config that discards the query params from the token. This is visible if you log the navigation event.

A better alternative is described here: https://gist.github.com/pleasetrythisathome/d1d9b1d74705b6771c20#file-browser-cljs-L11

noprompt commented 9 years ago

The secretary readme describes a google closure history config that discards the query params from the token.

@julienfantin I don't recall this being an issue but if it is we apologize. If you'd like to update the README and examples with something better please do.

mking commented 8 years ago

FWIW I just ran into this issue. query-params were coming back as nil until I used the history config in the above gist.