alephjs / aleph.js

The Full-stack Framework in Deno.

Home Page:https://alephjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Routing catches paths in incorrect order

ArtemSBulgakov opened this issue · comments

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).

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;