AlexGalays / abyssa-js

Framework agnostic hierarchical router for single page applications
MIT License
71 stars 9 forks source link

bugfix : redirect on init #38

Closed AurelienRichez closed 6 years ago

AurelienRichez commented 6 years ago

Currently, if a redirect happens during initialization, we end up with two entries in history (first entry when the browser open the page, second from the redirection).

When the user goes back in the history, il goes back to the first entry which redirects to the second one :-(, so history.back() becomes unusable unless we go back 2 states at once.

This PR changes this behaviour :

We added the corresponding tests.

AlexGalays commented 6 years ago

So, just to be sure: Any number of redirections while transitionning worked (only one history state pushed) but only on subsequent state changes, not during init?

AurelienRichez commented 6 years ago

@AlexGalays Yes. Transitions worked fine after initialization (only one pushed state even with several redirects). The problem happened if a transition occured during init. There was also one pushed state but a replaceState seems more consistent in this case to avoid "polluting" the history.

This changes the behaviour of abyssa but I don't know if adding this as a configurable parameter would be really useful 🤔.

AlexGalays commented 6 years ago

In general I think the number of config params should be kept to an absolute minimum :D Not polluting the history seems like it's a bug fix rather than a new way of doing things so I'm fine the way you did it.

AlexGalays commented 6 years ago

Fixed in 8.0.8