Skip to content
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

Warning of invalid param for catch all route with named route redirect #1617

Open
jfrs opened this issue Nov 19, 2022 · 7 comments
Open

Warning of invalid param for catch all route with named route redirect #1617

jfrs opened this issue Nov 19, 2022 · 7 comments
Labels
enhancement New feature or request good first issue Good for newcomers has workaround A workaround has been found to deal with the issue

Comments

@jfrs
Copy link

jfrs commented Nov 19, 2022

Version

4.1.6

Reproduction link

jsfiddle.net/z0kytrqj/16/

Steps to reproduce

Navigate to a catch all route with a named route redirect

  {
    path: '/:pathMatch(.*)*',
    redirect: { name: 'HOME' }
  }

What is expected?

No warnings

What is actually happening?

Warning displayed: Discarded invalid param(s) "pathMatch" when navigating. See https://github.com/vuejs/router/blob/main/packages/router/CHANGELOG.md#414-2022-08-22 for more details.

@posva posva added enhancement New feature or request good first issue Good for newcomers has workaround A workaround has been found to deal with the issue labels Nov 19, 2022
@posva
Copy link
Member

posva commented Nov 19, 2022

This is due to the implicit parameter being passed during a redirection. You can workaround it by passing an empty object of Params alongside the name of the route: redirect: { name: 'home', params: {} } or a function to pick the params you want: redirect: to => ({ name: '...', params: { id: to.id }})

I’m unsure if this warning can be avoided without removing it. Worst case scenario we can also mention the workaround in the warning

@jfrs
Copy link
Author

jfrs commented Nov 19, 2022

This works, thank you.

I have no strong opinion on this, I understand why the warning is there since I'm redirecting to a route that has no parameters so the workaround makes sense to me.

@sophoniie

This comment was marked as outdated.

This comment was marked as outdated.

@ashutosh887
Copy link

@posva I would like to work on this

@bblanchon

This comment was marked as resolved.

@posva

This comment was marked as resolved.

bblanchon added a commit to bblanchon/ArduinoJsonAssistant that referenced this issue Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers has workaround A workaround has been found to deal with the issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants