Skip to content

fix: add normalization for repeatable parameters - #4137

Open
rastuhacode wants to merge 1 commit into
nuxt-modules:mainfrom
rastuhacode:fix/stack-trailing-slashes
Open

fix: add normalization for repeatable parameters#4137
rastuhacode wants to merge 1 commit into
nuxt-modules:mainfrom
rastuhacode:fix/stack-trailing-slashes

Conversation

@rastuhacode

@rastuhacode rastuhacode commented Aug 14, 2026

Copy link
Copy Markdown

🔗 Linked issue

Resolves #4135

📚 Description

With trailingSlash: true, route localiztion creates:

/:slug(.*)*/
/fr/:slug(.*)*/

Vue Router parses it like:

// Url: .../test/
{ slug: ['test', ''] }

Then switchLocalePath() copies those params into the localized named route. Vue Router joins the array as test/, then the localized route pattern adds its configured slash, so basically happens:

/fr/ + test/ + / = /fr/test//

Navigating there produces another empty parameter element, so the process repeats indefinitely.
The malformed SEO URLs are a downstream symptom: locale head generation calls switchLocalePath() for canonical and alternate URLs.

Solution

  • Added normalization process for repeatable params (normalizeRepeatableParams), which removes only trailing empty elements from repeatable route params before named-route resolution.
  • Added regression tests

Summary by CodeRabbit

  • Bug Fixes
    • Improved localized route handling for repeatable and catch-all parameters.
    • Preserved interior empty path segments while removing unnecessary trailing segments.
    • Ensured locale switching and route resolution produce consistent URLs.
    • Corrected canonical localized URLs to use exactly one trailing slash where applicable.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7fffa2c8-0df5-474d-8157-d7e536104542

📥 Commits

Reviewing files that changed from the base of the PR and between 6a72568 and 274f2ac.

📒 Files selected for processing (2)
  • src/runtime/routing/routing.ts
  • test/routing-head.test.ts

Walkthrough

The routing implementation adds normalization for repeatable route parameters. It removes trailing empty array elements and preserves interior empty elements before named localized route resolution. The routing tests add configurable route records and trailing-slash behavior, then cover catch-all routes, locale switching, URL queries and hashes, route consistency, and canonical trailing-slash URLs.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 274f2

The change normalizes trailing empty repeatable route parameters to prevent duplicate slashes in localized URLs; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: normalization for repeatable route parameters.
Linked Issues check ✅ Passed The implementation and regression tests address duplicate trailing slashes for catch-all routes and localized URL generation in issue #4135.
Out of Scope Changes check ✅ Passed The source and test changes are directly related to repeatable parameter normalization and the linked trailing-slash bug.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@rastuhacode

rastuhacode commented Aug 14, 2026

Copy link
Copy Markdown
Author

UPD: The PR which resolves the same issue #4136

I kept this open for reference and just in case. Maintainers can close it if they find it unuseful.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: trailingSlash produces double slash for catch-all routes in useLocaleHead and useSwitchLocalePath

1 participant