Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single letter folder named 't' breaks the routes #188

Closed
jemmyw opened this issue Jan 11, 2025 · 3 comments
Closed

Single letter folder named 't' breaks the routes #188

jemmyw opened this issue Jan 11, 2025 · 3 comments

Comments

@jemmyw
Copy link

jemmyw commented Jan 11, 2025

Describe the Bug

I wanted a route like /t/:token in my app. However, using the letter 't' for a folder seems to break things. Using the letter 'a' doesn't break things, and 'to' works. !

Here is the routes generated with 't':

CleanShot 2025-01-11 at 12 57 32@2x

Note that 't' doesn't appear in the children array and the account path has '(app)/t/_layout' as it's id.

Now if I rename the folder to 'a':

CleanShot 2025-01-11 at 12 59 08@2x

Now 'a' appears as one of the children and the account path id is '(app)/account/_layout' as expected.

Generouted Version

1.19.9

Your Example Website or App or Reproduction

N/A

Steps to Reproduce the Bug or Issue

  1. Name a folder 't' in src/pages

Expected Behavior

To be able to use /t/ as a path

Screenshots or Videos

No response

Platform

  • macOS
  • Chrome

Additional context

No response

@jemmyw
Copy link
Author

jemmyw commented Jan 11, 2025

I've narrowed this down. When having two sibling routes under a route group (app), if one route is a single letter (e.g., 't') and another route exists that comes before it and ends with that letter (e.g., 'account'), the single-letter route gets incorrectly nested as a child of the other route instead of being a sibling.

It looks like this is the code causing an issue:

const found = current?.find((route) => route.path === path || route.id?.replace('/_layout', '').endsWith(path))

in packages/generouted/src/core.ts

And note the problem exists for 'nt 'unt' 'ount' 'count' and 'ccount'

@oedotme
Copy link
Owner

oedotme commented Jan 12, 2025

@jemmyw Thanks for reporting and fixing this issue!

I've applied the commit you've referenced and included that in the tests.

This should be available now in the v1.19.10 release.

@jemmyw
Copy link
Author

jemmyw commented Jan 18, 2025

Thanks for resolving!

@jemmyw jemmyw closed this as completed Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants