Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unmatched route with root option and popstate event #82

Closed
sndrgb opened this issue Aug 18, 2015 · 0 comments
Closed

Unmatched route with root option and popstate event #82

sndrgb opened this issue Aug 18, 2015 · 0 comments

Comments

@sndrgb
Copy link

sndrgb commented Aug 18, 2015

Hi, this was my scenario:

  1. route initialized with history option true and root option set to /en like this:
router = new Router({
    history: true,
    root: utils.lang
});
  1. navigating from homepage ( /en ) to contact ( /en/contact )

  2. clicking back button for come back to homepage ( /en ) matches default '404' route ( * )

after some tries and investigations i think i've found a little bug in /src/history/html5.js p.start method where this.listener function loses its context. i resolve binding the function to this

 this.listener = function (e) {
    var url = decodeURI(location.pathname + location.search)
    if (this.root) {
      url = url.replace(this.rootRE, '')
    }
    self.onChange(url, e && e.state, location.hash)
  }.bind(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant