mirror of
https://github.com/withastro/astro.git
synced 2025-01-27 22:19:04 -05:00
227cd83a51
* Reproduce regression * Simplify sorting algorithm * Add changeset * Fix changeset typo * Rename assertion utility function * Fix index detection * Add changeset for index fix --------- Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
23 lines
1.2 KiB
Markdown
23 lines
1.2 KiB
Markdown
---
|
|
"astro": patch
|
|
---
|
|
|
|
Fixes regression on routing priority for multi-layer index pages
|
|
|
|
The sorting algorithm positions more specific routes before less specific routes, and considers index pages to be more specific than a dynamic route with a rest parameter inside of it.
|
|
This means that `/blog` is considered more specific than `/blog/[...slug]`.
|
|
|
|
But this special case was being applied incorrectly to indexes, which could cause a problem in scenarios like the following:
|
|
- `/`
|
|
- `/blog`
|
|
- `/blog/[...slug]`
|
|
|
|
The algorithm would make the following comparisons:
|
|
- `/` is more specific than `/blog` (incorrect)
|
|
- `/blog/[...slug]` is more specific than `/` (correct)
|
|
- `/blog` is more specific than `/blog/[...slug]` (correct)
|
|
|
|
Although the incorrect first comparison is not a problem by itself, it could cause the algorithm to make the wrong decision.
|
|
Depending on the other routes in the project, the sorting could perform just the last two comparisons and by transitivity infer the inverse of the third (`/blog/[...slug` > `/` > `/blog`), which is incorrect.
|
|
|
|
Now the algorithm doesn't have a special case for index pages and instead does the comparison soleley for rest parameter segments and their immediate parents, which is consistent with the transitivity property.
|