The default option for case sensitivity in path-to-regexp is false and I couldn't find an option to set it from a new Vue router instance. I'm trying to redirect some old paths in a project to new ones, and some of these new paths are just capitalized versions of the old, like /all-stores to /All-Stores but this causes an infinite redirect loop with the current setting.
Hello! URIs are case insensitive (even if servers can handle them differently), so there's no reason to add an option to allow creating case sensitive routes to vue-router. It'll make things confusing and allow people to create routes that are wrong.
Although schemes are case-
insensitive, the canonical form is lowercase and documents that
specify schemes must do so with lowercase letters.
(https://tools.ietf.org/html/rfc3986#section-3.1)
Hey @posva The specification you posted there is only talking about the scheme (http, ftp, ws, etc...) According to the rfc spec the scheme and host are case insensitive, but the path portion of the URI is supposed to be case sensitive.
From https://tools.ietf.org/html/rfc3986#section-6.2.2.1
For all URIs, the hexadecimal digits within a percent-encoding
triplet (e.g., "%3a" versus "%3A") are case-insensitive and therefore
should be normalized to use uppercase letters for the digits A-F.When a URI uses components of the generic syntax, the component
syntax equivalence rules always apply; namely, that the scheme and
host are case-insensitive and therefore should be normalized to
lowercase. For example, the URI HTTP://www.EXAMPLE.com/ is
equivalent to http://www.example.com/. The other generic syntax
components are assumed to be case-sensitive unless specifically
defined otherwise by the scheme.
According to that the scheme, host and the hexidecimal parts of the path are case insensitive, but all other components should be case sensitive.
but all other components should be case sensitive.
Sorry, but there is no such statement in the RFC.
That link above (https://tools.ietf.org/html/rfc3986#section-6.2.2.1) does say the other components are assumed to be case-sensitive.
The other generic syntax
components are assumed to be case-sensitive unless specifically
defined otherwise by the scheme (see Section 6.2.3).
And Section 6.2.3 (https://tools.ietf.org/html/rfc3986#section-6.2.3) has no mention of the path, so we can assume it to be case sensitive.
I see that statement in the RFC...
And nothing in the HTTP 1.1 RFC (https://tools.ietf.org/html/rfc7230#section-2.7) states otherwise, so it seems to me that the path should be case sensitive.
GoogleBot also treats paths as case sensitive so there's some accepted industry practices as well.
assumed to be isn't equivalent of required to be(or should be).
Case sensitivity for urls is generally decided by implementations as of today. Most sites (including Github) treats urls as case-insensitive. There is no practical advantage of using case sensitive urls - users simply don't bother to type cased urls in to the browser.
So if you are saying that assumed to be is not the same as required to be and should be decided by the implementation. Then it seems to make more sense to allow the developers to decide if they want their URIs to be case sensitive or insensitive, not the library's.
Case sensitivity for urls is generally decided by implementations
I would think this reasoning is exactly why case sensitivity in urls should be an option in the vue router.
That way the implementation can decide if urls should be case sensitive.
IMHO the application using the framework is the implementation and should make implemenation decisions. As the framework, vue should empower the application to make these types of decisions.
Well, PRs are always welcome.
Paths should not be case sensitive but they can. On the other hand, query params like ?query=Hello are always case sensitive.
I overlooked the first thing and thought they couldn't, sorry for that. Makes sense to support it, indeed.
About the implementation: an SPA is half of the implementation, the other half being the server. If a user activates the case-sensitive paths, he also needs to make sure the server treats them correspondingly. But I'm pretty sure that's the default behaviour. For instance, Google cares about it while Stack Overflow doesn't.
If you want to submit a PR, you need to add an option like caseSensitive or a pathToRegexpOptions that can contain other attributes like strict (looks like the only one that is useful too) to the RouteConfig type https://github.com/vuejs/vue-router/blob/dev/flow/declarations.js#L32 and then pass it down until getRouteRegex. I think the caseSensitive option looks better. Hope it helps.
Thanks, i will work on a PR
Submitted PR #1215
Most helpful comment
Well, PRs are always welcome.