N
Nuxt3mo ago
jess

useRoute trailingSlash changes in 3.17.5

I recently upgraded from 3.15.4 to 3.17.5 and I noticed that useRoute() no longer trims the trailing slash on the route. Is this intended? Are there any issues around this? Is there a central workaround?
2 Replies
kapa.ai
kapa.ai3mo ago
Hi @jess. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the available knowledge sources, there is no explicit documentation or changelog entry stating that the behavior of useRoute() regarding trailing slashes was intentionally changed in Nuxt 3.17.5. However, there is evidence that the handling of trailing slashes and route resolution has been an area of active development and fixes in recent Nuxt versions. Notably: - There have been recent features and fixes related to trailingSlash configuration at the app level, affecting how Nuxt handles trailing slashes in routes and links. For example, you can now set app.trailingSlash to 'append' or 'remove' in nuxt.config, which influences route and link generation, but the direct impact on useRoute()'s output is not detailed in the sources feat(nuxt): trailingSlash config & createRouteResolver util. - The NuxtLink component now supports a trailingSlash prop for per-link control, but again, this is about link generation, not the route object itself feat(nuxt): add trailingSlash prop to NuxtLink. - There are no open or closed issues in the provided sources specifically reporting a change or bug in useRoute()'s handling of trailing slashes in 3.17.5. If you are observing that useRoute() now preserves the trailing slash (whereas before it trimmed it), this may be a side effect of the recent changes to route resolution and trailing slash handling, but the knowledge sources do not confirm whether this is intended or a regression. Workarounds:
There is no central workaround documented in the sources for normalizing trailing slashes in useRoute(). If you need consistent behavior, you may need to manually normalize route paths in your code until more official guidance is available. Summary:
- The change you observe is not explicitly documented as intended in the sources. - There is no central workaround provided in the official docs or changelogs. - If this change breaks your app, consider opening an issue on the Nuxt repo with a reproduction. If you need to enforce a specific trailing slash behavior, you can use the app.trailingSlash config for link generation, but for useRoute(), manual normalization may be necessary for now. If you have more context or a specific reproduction, the Nuxt team is responsive to such reports, as seen in related issues. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3mo ago
<@212548363529355264> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?