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

Incorrect routing of anchors when root is set #26

Open
nrbrook opened this issue Nov 13, 2014 · 3 comments
Open

Incorrect routing of anchors when root is set #26

nrbrook opened this issue Nov 13, 2014 · 3 comments
Labels

Comments

@nrbrook
Copy link

nrbrook commented Nov 13, 2014

When a non-empty root is set during router start, routing of clicked anchors fails.

This happens because the anchor pathname is used, which includes the root, which is passed to navigate, which passes that to getFragment, which fails to remove the root from the fragment.

@nrbrook
Copy link
Author

nrbrook commented Nov 13, 2014

Temp fix:

    this.router = new Router();
    var oldGetFragment = this.router.history.getFragment;
    this.router.history.getFragment = function (fragment) {
        if(fragment) {
            var root = this.root.slice(1);
            if (!fragment.indexOf(root)) fragment = fragment.slice(root.length);
        }
        return oldGetFragment.call(this, fragment);
    };

@bear bear added the bug label Nov 13, 2014
@ruiramos
Copy link

Just ran into the same problem, thanks @nrbrook, it would be a valuable fix in ampersand-history!

@nikolenkoanton92
Copy link

I got same bug today, @nrbrook thanks for temp solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants