-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Unexpected behavior when a path parameter value matches the path parameter name #33703
Comments
https://vercel.com/support/articles/[slug] has also crashed on me |
Thanks, I could reproduce this locally with the following:
import { useRouter } from "next/router"
export default function Page() {
const router = useRouter()
return <pre>{JSON.stringify(router.query, null, 2)}</pre>
} Just to investigate further, do you have a valid use case for this? 🤔 |
Not in particular, but errors from this behavior popped up in my production logs for access to a similar URL (may have come from bad internal URL building) I decided to raise this issue since it's a case of unfortunate interpolation/escaping similar to the one I addressed in #31523 |
The main thing here is that it feels like a breach of API contract that there is a scenario where I don't want to have to check for that in all of my dynamic routes :( |
I actually found this is a duplicate of #23824, so I'm going to close this issue in favor of the one that was reported earlier. Thank you for the investigation anyway, I'll backlink to this issue as well. |
Add tests for the cases described in vercel#33703 and vercel#23824 as well as a few more.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What version of Next.js are you using?
12.0.8-canary.6
What version of Node.js are you using?
whatever vercel.com is on
What browser are you using?
Chrome 97
What operating system are you using?
Windows
How are you deploying your application?
Vercel
Describe the Bug
For a URL like https://vercel.com/changelog/[item] to a page
/changelog/[item].tsx
,useRouter().query
returns an empty object{}
.Expected Behavior
For a URL like https://vercel.com/changelog/[item] to a page
/changelog/[item].tsx
, one would expectuseRouter().query
to return{ item: "[item]" }
To Reproduce
Request a path parameter's name as its value: https://vercel.com/changelog/[item]
The text was updated successfully, but these errors were encountered: