TanStack / router

🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering.
https://tanstack.com/router
MIT License
7.8k stars 572 forks source link

NotFound route when refreshing or manual url to a route with special characters #1959

Closed Hampton-Matt closed 2 months ago

Hampton-Matt commented 2 months ago

Describe the bug

Using the file based routing with file names/routes that have special characters, in my case it is accented characters such as â or é etc., causes not found issues. (Running using vite and the file based plugin)

Manually routing to a page, i.e. typing in a url and hitting enter, or refreshing or opening in a new tab, throws notfound and consequentally will render the 404 or notfound component.

I can easily fix it by renaming my files to use english characters only but thought I would flag it anyway.

Your Example Website or App

https://stackblitz.com/edit/github-sxumx6?file=src%2Froutes%2Fex%C3%A2mple.tsx,src%2Froutes%2F__root.tsx

Link that actually throws not found instead of routing: https://wmaibnrpmngithub-zclp--3001--70dbe416.local-corp.webcontainer.io/exâmple

Steps to Reproduce the Bug or Issue

  1. Create a new route / file with special characters like é
  2. Let routetree.gen generate
  3. Route to page using app to check it is working
  4. Then refresh, open in new tab or manually retype url to reproduce issue (will throw a 404 instead of routing)

Expected behavior

It should route to the page but instead 404s the exisiting route

Screenshots or Videos

No response

Platform

Additional context

No response

SeanCassiere commented 2 months ago

I'm not sure if this is something that needs "fixing". As per RFC 3986, the URL only supports ASCII characters and everything else (i.e. Unicode characters) should be URL encoded with the percent sign.

Edit: More resources on this.

SeanCassiere commented 2 months ago

Thinking on this a bit more, it isn't too much effort for the router to perform these checks under the hood.

I'll work on shipping this soon.

SeanCassiere commented 2 months ago

This has been completed as of the 1.45.2 release.

themsv commented 3 weeks ago

I am facing a similar issue, when I manually type the route in URL, I am getting a Not found error. But I navigate using it works. But interestingly locally(development) this issue is not happening but happens on the deployed site.

SeanCassiere commented 3 weeks ago

I am facing a similar issue, when I manually type the route in URL, I am getting a Not found error. But I navigate using it works. But interestingly locally(development) this issue is not happening but happens on the deployed site.

@themsv Please create an issue with a reproduction.