svelte-routing icon indicating copy to clipboard operation
svelte-routing copied to clipboard

Case insensitive routing

Open JamJar00 opened this issue 6 years ago • 3 comments

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.

JamJar00 avatar Sep 07 '19 23:09 JamJar00

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.

EmilTholin avatar Feb 28 '20 10:02 EmilTholin

could this have any unexpected impacts on path names or queries that contain hashed values / tokens?

clockelliptic avatar Mar 07 '20 20:03 clockelliptic

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.

JamJar00 avatar Mar 08 '20 21:03 JamJar00

Svelte Routing v1.8 has been released, which has this feature..

krishnaTORQUE avatar May 05 '23 14:05 krishnaTORQUE