Mismatch of dynamic route with multiple parameters when one contains hyphens #7265
Closed
1 task done
Labels
- P4: important
Violate documented behavior or significantly impacts performance (priority)
What version of
astro
are you using?2.5.6
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
npm
What operating system are you using?
MacOS Ventura 13.4
What browser are you using?
Chrome latest
Describe the Bug
For a slug with hyphens:
my-first-blog
: if I name my page[id]-[slug].astro
the dynamic route will be matched. If I name my page[slug]-[id].astro
it will not be matched. In that latter version I think Astro matchesmy-
and then expects anid
instead offirst-blog
.The above code works perfectly fine. If I change the file name to
[slug]-[id].astro
, I get a 404 on that routemy-first-blog-1
and the Astro CLI will sayI can imagine this is expected behaviour, but there's nothing in the docs or some sort of hint in errors that tells you to set up your route differently (an effective fix is creating the whole slug inside
getStaticPaths()
:slug: `${post.slug}-${post.id}`
but I'd rather go by the book). Thanks!PS in the stackblitz example, if you rename the route to
[slug]-[id].astro
you will reproduce this behaviour.Link to Minimal Reproducible Example
https://stackblitz.com/edit/astro-custom-slugs-smqxwc?file=src%2Fpages%2Findex.astro
Participation
The text was updated successfully, but these errors were encountered: