Skip to content

fix(router-core): correct splat param extraction after a skipped optional param - #6434

Merged
Sheraff merged 1 commit into
mainfrom
fix-router-core-optional-and-wildcard-param-extraction-index
Jan 21, 2026
Merged

fix(router-core): correct splat param extraction after a skipped optional param#6434
Sheraff merged 1 commit into
mainfrom
fix-router-core-optional-and-wildcard-param-extraction-index

Conversation

@Sheraff

@SheraffSheraff commented Jan 21, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes

    • Fixed route parameter extraction to properly align path segments when optional parameters are skipped during route matching.
  • Tests

    • Added test coverage for route matching scenarios with optional parameters followed by wildcard segments.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitaiBot commented Jan 21, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR fixes a bug in the extractParams function where pathIndex wasn't being properly decremented when handling optional parameter segments with skipped nodes. A test case verifying the fix with a skipped optional parameter followed by a wildcard segment is also added.

Changes

Cohort / File(s)Summary
Bug Fix
packages/router-core/src/new-process-route-tree.ts
Decrements pathIndex by 1 when handling OPTIONAL_PARAM segment with a skipped node, ensuring proper alignment between path segments and route parameter extraction.
Test Coverage
packages/router-core/tests/new-process-route-tree.test.ts
Adds new test case "skipped optional, ends with wildcard" validating parameter extraction for route pattern /{-$foo}/bar/$ matching path /bar/rest.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • schiller-manuel
  • nlynzaad

Poem

🐰 A path once wandered, confused and slow,
With optional skips that threw pathIndex low.
Now properly decremented, the segments align,
Wildcards catch rest with a fix so fine! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title accurately describes the main change: fixing splat parameter extraction after a skipped optional parameter, which is exactly what the code modifications address.
Docstring Coverage✅ PassedDocstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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

@nx-cloud

nx-cloudBot commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 4f19845

CommandStatusDurationResult
nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded9m 23sView ↗
nx run-many --target=build --exclude=examples/*...✅ Succeeded1m 38sView ↗

☁️ Nx Cloud last updated this comment at 2026-01-21 11:23:03 UTC

@pkg-pr-new

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@6434

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@6434

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@6434

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@6434

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@6434

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@6434

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@6434

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@6434

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@6434

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@6434

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@6434

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@6434

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@6434

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@6434

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@6434

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@6434

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@6434

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@6434

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@6434

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@6434

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@6434

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@6434

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@6434

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@6434

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@6434

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@6434

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-fn-stubs@6434

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@6434

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@6434

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@6434

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@6434

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@6434

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@6434

@tanstack/vue-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router@6434

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-devtools@6434

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-ssr-query@6434

@tanstack/vue-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start@6434

@tanstack/vue-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-client@6434

@tanstack/vue-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-server@6434

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@6434

commit: 4f19845

@Sheraff
Sheraff merged commit 9c934b7 into mainJan 21, 2026
6 checks passed
@Sheraff
Sheraff deleted the fix-router-core-optional-and-wildcard-param-extraction-index branch January 21, 2026 11:27
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@Sheraff