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

Root is case sensitive, should be case insensitive #46

Open
vuorinem opened this issue Feb 7, 2019 · 1 comment
Open

Root is case sensitive, should be case insensitive #46

vuorinem opened this issue Feb 7, 2019 · 1 comment

Comments

@vuorinem
Copy link

vuorinem commented Feb 7, 2019

I'm submitting a bug report

  • Library Version:
    1.3.0

  • Browser:
    all

  • Language:
    all

Current behavior:
When the casing of root (which is the baseUrl passed on from the router) does not match to current root, the application fails to navigate to any route.

  • What is the expected behavior?
    Navigation should not rely on exact casing of the root.

  • What is the motivation / use case for changing the behavior?
    The route-recognizer is case-insensitive (with an option to specify individual routes as case-sensitive, see Case sensitive router router#271). The baseUrl should probably have similar behaviour, or at least have an option to specify it as case-insensitive.

As far as I could tell, there are two places in history-browser that are affected:

if (!fragment.indexOf(root)) {
fragment = fragment.substr(root.length);
}

let atRoot = loc.pathname.replace(/[^\/]$/, '$&/') === this.root;

@LordBenjamin
Copy link

Naively addressed by changing those two snippets to:

var atRoot = loc.pathname.replace(/[^\/]$/, '$&/').toUpperCase() === this.root.toUpperCase();

and

if (!fragment.toUpperCase().indexOf(root.toUpperCase())) {

This will not cope with various unicode characters etc.

Should consider using localeCompare() instead. Unsure whether sensitivity: base or sensitivity: accent would be more appropriate for a URI - I'm guessing accent?

Is there any case where we would want to enfore case-sensitivity? (i.e. should this be opt-in functionality?)

Is this still relevant in the latest history-browser version?

Any other areas of the code that might need to account for case (in)sensitivity?

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

2 participants