svelte-routing
svelte-routing copied to clipboard
Case insensitive routing
Would be nice to have case insensitivity as an option on the Router component so that routes don't need to be redefined.
In my current project I have links to pages formerly using title case paths, so now need to have routes for both cases:
<Router>
<Route path="page1" component={Page1} />
<Route path="page2" component={Page2} />
<Route path="Page1" component={Page1} />
<Route path="Page2" component={Page2} />
</Router>
It might be nicer to be able to do say:
<Router caseSensitive={false}>
<Route path="page1" component={Page1} />
<Route path="page2" component={Page2} />
</Router>
Or even be able to override case sensitivity on a per-route basis for more control.
Hi @JamJar00!
I like the idea, but I will have to research if there are any ramifications to this, and if the case sensitivity should be off by default for backwards compatibility, etc.
could this have any unexpected impacts on path names or queries that contain hashed values / tokens?
I think so long as it's opt-in then in worst case someone can revert back to case-sensitive routing if necessary.
I wonder if adding additional options such as regex based matching, for example, would aid more nieche use cases. For example if one has a case-sensitive hash in the middle of their path they could use a regex to ensure that part was not treated case-insensitively.
Svelte Routing v1.8 has been released, which has this feature..