mirror of
https://github.com/TanStack/router.git
synced 2026-11-16 19:38:07 +00:00
When ordering routes to determine "which one will match in priority", we
try to follow the "more specific 1st" principle.
Currently, 2 routes with the same pattern, but with prefixes of
different lengths, are counted as having the same specificity, and thus
are not re-ordered. For example:
- `/f{$param}`
- `/foo{$param}`
In this case, assuming `f{$param}.tsx` is returned 1st by the OS when
listing route files (which it is by alphabetical order), a path
`/foobar` will match `/f{$param}`.
This PR proposes we take the `length` of the `prefix` and `suffix` into
account when sorting routes. In this example this would mean
`/foo{$param}` takes priority because it is considered more specific.
454 lines
16 KiB
454 lines
16 KiB