Skip to content

getRouteBaseName documentation is missleading #3541

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

Open
tkalmar opened this issue Apr 10, 2025 · 3 comments
Open

getRouteBaseName documentation is missleading #3541

tkalmar opened this issue Apr 10, 2025 · 3 comments

Comments

@tkalmar
Copy link

tkalmar commented Apr 10, 2025

Environment

does not matter

Reproduction

getRouteBaseName

Describe the bug

The documentation states Returns base name of current (if argument not provided) or passed in route. but if no route is given the result is undefined.

So please either adjust the documentation or the implementation.

Additional context

No response

Logs

@BobbieGoede
Copy link
Member

You're right that the internal function has incorrect JSDocs, I think the behavior would be nice and will consider adopting it in v10 since it could be a breaking/unexpected behavior change.

I'm curious how you arrived at those JSDocs, because the actual documentation on i18n.nuxtjs.org and exposed composable JSDoc do not describe this behavior.

@tkalmar
Copy link
Author

tkalmar commented Apr 11, 2025

In the v7 docs https://v8.i18n.nuxtjs.org/v7/api#getroutebasename the behaviour is described as in the (internal) docs so i wondered why this changed and looked at the code...

@BobbieGoede
Copy link
Member

Oh, I wasn't aware of this being described in the old documentation.

I think this change may have been made due to some confusing behavior where the currentRoute is unset in some situations (like global middleware), in which case it would return undefined when no argument was provided. I'm not sure if this edge case was present in Nuxt 2 though 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants