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

Routing catches paths in incorrect order #526

Open
ArtemSBulgakov opened this issue Jan 27, 2023 · 1 comment
Open

Routing catches paths in incorrect order #526

ArtemSBulgakov opened this issue Jan 27, 2023 · 1 comment

Comments

@ArtemSBulgakov
Copy link

Dynamic routes should not be caught before any other routes.

Example 1

I have the following structure:

/routes/$pageId+.tsx
/routes/posts/index.tsx
/routes/posts/$id.tsx

The route $pageId+ catches all paths. The user cannot get /posts or /posts/$id, these paths are caught by the first route.

Example 2

I have the following structure (notice $pageId without +):

/routes/$pageId.tsx
/routes/posts/index.tsx
/routes/posts/$id.tsx

The user cannot get /posts, that path is caught by the $pageId route (only /posts/index is working for that page).

@ArtemSBulgakov
Copy link
Author

I think the following formula should be changed somehow to order dynamic routes after other routes

return filename.split("/").length + (pattern.pathname.split("/:").length - 1) * 0.01;

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

1 participant