-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
next/link as
prop throw an error with optional catch all routes using URL Object syntax
#41624
Closed
1 task done
Labels
bug
Issue was opened via the bug report template.
Comments
3 tasks
ijjk
pushed a commit
that referenced
this issue
Nov 10, 2022
In `Link`, `router.push`, and `router.replace`, `as` option used to throw for optional catch all routes with url object syntax: optional attribute were not taken into account when checking missing parameters in router change method. This PR just add a condition in the filter callback to filter out optional routes. Fixes #41624 ## Bug - [X] Related issues linked using `fixes #number` - [X] Integration tests added - [X] Errors have a helpful link attached, see `contributing.md`
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Verify canary release
Provide environment information
What browser are you using? (if relevant)
All
How are you deploying your application? (if relevant)
Both
next dev
andnext start
Describe the Bug
Given the following pages structure:
And the following rewrite:
This works (or seems to work but prefetch fails, see this issue: I get rid of it using URL Object syntax with non optional catch all routes, but... please read further):
But using URL Object syntax, it does not work at all:
Neither this:
The last two throw the following error on click:
Error: The provided `as` value (/blog) is incompatible with the `href` value (/news/[[...slug]]). Read more: https://nextjs.org/docs/messages/incompatible-href-as
.Expected Behavior
URL Object syntax should work as well as string synthax.
Link to reproduction
Github repo
Codesandbox
Codesandbox deployment
To Reproduce
Just visit the above Codesandbox deployment, and try the links.
The text was updated successfully, but these errors were encountered: