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.85k stars 580 forks source link

Possible regression: Trailing and non trailing slash URLs match differently #625

Closed AkshayPathak closed 1 year ago

AkshayPathak commented 1 year ago

Describe the bug

URLs ending in / do match the same as without the /. Possible regression of #370.

Your Example Website or App

https://tanstack.com/router/v1/docs/examples/react/kitchen-sink-multi-file?file=src%2Fmain.tsx

Steps to Reproduce the Bug or Issue

  1. Go to Dashboard and Invoices
  2. Observe that Create a new Invoice section is visible
  3. Add a trailing slash to the URL

The Create a new Invoice section disappears.

Expected behavior

Content of trailing slashes should match as non-trailing slash urls.

Screenshots or Videos

No response

Platform

Additional context

No response

tannerlinsley commented 1 year ago

Good catch. I’ll check it out.

Tanner Linsley On Jul 7, 2023 at 10:48 PM -0600, Akshay Pathak @.***>, wrote:

Describe the bug URLs ending in / do match the same as without the /. Possible regression of #370. Your Example Website or App https://tanstack.com/router/v1/docs/examples/react/kitchen-sink-multi-file?file=src%2Fmain.tsx Steps to Reproduce the Bug or Issue

  1. Go to Dashboard and Invoices
  2. Observe that Create a new Invoice section is visible
  3. Add a trailing slash to the URL

The Create a new Invoice section disappears. Expected behavior As documented by the docs, trailing slashes should match as non-trailing slash urls. Screenshots or Videos No response Platform

• OS: Linux • Browser: Chrome

Additional context No response — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

tannerlinsley commented 1 year ago

I can't replicate in the latest version. The page comes up for both non and trailing slash versions.

AkshayPathak commented 1 year ago

Seems like this was fixed in latest version. Thanks!

SuchMonkey commented 1 year ago

I'm sorry to revive this but it seems to be broken again. Or maybe I'm just misunderstanding the intended behavior.

Reproduction using the Kitchen Sink Multi File example go to /dashboard -> dashboard page comes up go to /dashboard/ -> dashboard page comes up

go to /expensive -> expensive page comes up go to /expensive/ -> no expensive page comes up

In summary If there is no index page assigned to a route it will not match if there is a trailing slash. Maybe this is intended but I find it confusing.

A little motivation on why they should match We want to integrate our app in a Wordpress page. However WP really likes to rewrite URLs and they always end up with a trailing slash which results in a 404 in our app (we utilize a catch all route).

Tested versions 0.0.1-beta.134 0.0.1-beta.133 0.0.1-beta.119

Also, thanks for the great library and all the good work you put in :)

tannerlinsley commented 1 year ago

This is an easy fix. I’ll get on it

Tanner Linsley On Aug 3, 2023 at 5:10 AM -0600, SuchMonkey @.***>, wrote:

I'm sorry to revive this but it seems to be broken again. Or maybe I'm just misunderstanding the intended behavior. Reproduction using the Kitchen Sink Multi File example go to /dashboard -> dashboard page comes up go to /dashboard/ -> dashboard page comes up go to /expensive -> expensive page comes up go to /expensive/ -> no expensive page comes up In summary If there is no index page assigned to a route it will not match if there is a trailing slash. Maybe this is intended but I find it confusing. A little motivation on why they should match We want to integrate our app in a Wordpress page. However WP really likes to rewrite URLs and they always end up with a trailing slash which results in a 404 in our app (we utilize a catch all route). Tested versions 0.0.1-beta.134 0.0.1-beta.133 0.0.1-beta.119 Also, thanks for the great library and all the good work you put in :) — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you modified the open/close state.Message ID: @.***>

sobigyan commented 1 year ago

Is this not fixed in the latest version?

I tested on the latest verion v0.0.1-beta.145 with Quick Start example.

Routes with trailing slash are still not rendering

tannerlinsley commented 1 year ago

This was a regression! 🤦‍♂️ It's fixed in the latest release :)