Closed tolgap closed 6 years ago
Huh. That is pretty weird. I'm not totally sure where the bug here is either - could also be in Secretary. Will have to do some debugging.
I'm hitting this bug as well.
I use a custom transformer for the Html5History object: https://github.com/open-company/open-company-web/blob/mainline/src/open_company_web/router.cljs inspired by this: https://github.com/Sparrho/supper-demo/blob/master/src-cljs/supper/history.cljs
Wondering if anyone figured this out?
I'd welcome a PR to fix this.
I solved this problem by adding the following code above the accountant/configure-navigation! call:
(set! accountant/history.transformer_
(let [transformer (goog.history.Html5History.TokenTransformer.)]
(set! (.. transformer -retrieveToken)
(fn [path-prefix location]
(str (.-pathname location) (.-search location))))
(set! (.. transformer -createUrl)
(fn [token path-prefix location]
(str path-prefix token)))
transformer))
bago2k4's links were very helpful.
@pharcosyle 's code fixes it. Thank you!
I believe this has been resolved by #48.
Here's a small scenario:
I have a search input. The input changes the URL in its
on-change
attribute. The URL is changed from:localhost:3449/
tolocalhost:3449/?q=t
But when I keep tying the word
test
into the search input, the URL changes to:localhost:3449/?q=t?q=te?q=tes?q=test
.I have managed to track the issue down to this line in
core.cljs
line108
:It seems the
Html5History
API from the Google Closure Library does not keep track/return the query string when callinggetToken
on it, because it always returns"/"
, instead of"/?q=t"
etc.Is there any way I can work around this for now? I don't know if the issue is in the GCL
Html5History
API, or Accountant, or that I'm doing something wrong.