Skip to content

Conversation

@FrankFMY
Copy link
Contributor

@FrankFMY FrankFMY commented Feb 6, 2026

Summary

Fixes #13704. The prevent_conflicts function in create_manifest_data failed to detect conflicting routes when route groups were nested with optional parameters.

For example, /(group)/base/+page.svelte and /(group)/base/(optional-group)/[[optionalParam]]/+page.svelte both resolve to /base but the conflict was not detected.

Root cause: The regex on line 564 that removes duplicate slashes — .replace(/\/{2,}/, '/') — was missing the global g flag. When normalize_route_id removes group segments from a route like /(group)/base/(optional-group)/[[optionalParam]], it produces //base//<?*>. After expanding the optional parameter, one permutation is //base//. Without the g flag, only the first // is collapsed to /, leaving /base/ instead of base — which doesn't match the key base from the other route.

Fix: Add the g flag: .replace(/\/{2,}/g, '/').

Test plan

  • Added conflicting-nested-groups test sample with two routes that resolve to the same URL
  • All 425 existing unit tests pass

The regex in prevent_conflicts that removes duplicate slashes was
missing the global flag, so only the first occurrence of consecutive
slashes was replaced. This caused routes like /(group)/base and
/(group)/base/(optional-group)/[[param]] to not be detected as
conflicting because the second set of double slashes remained.

Fixes sveltejs#13704
@changeset-bot
Copy link

changeset-bot bot commented Feb 6, 2026

🦋 Changeset detected

Latest commit: 4807477

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

Routing conflict not detected in nested groups

1 participant