fix(router-core): Non-nested paths #5169
main fromrefs/pull/5169/head·merged by nlynzaad(GitHub profile, opens in a new tab) This PR continues on from #5165 and primarily adds additional tests to path resolution and matchByPath for non-nested paths in additiona to e2e test for both react and solid router to verify non-nesting functionality.
One additional issue was picked up for handling of normal path segments.
Summary by CodeRabbit#
- New Features
- Added non-nested demo routes and navigation examples (including dynamic and edit paths) for React and Solid, with headings, links, and parameter displays.
- Bug Fixes
- Improved path parsing/decoding for non-nested segments to prevent unintended nesting and ensure correct parameter values.
- Tests
- Added broad unit tests for non-nested path parsing/matching/resolution (case-sensitive/insensitive, wildcards, optional/fuzzy).
- Added e2e tests validating non-nested navigation and params; reduced e2e flakiness by awaiting network idle.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-core
View your CI Pipeline Execution ↗ for commit 0fa77f03c08f87fed5ce2b6425e4a46fba486a1f
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded 1m 58s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 2s View ↗
☁️ Nx Cloud last updated this comment at
2025-09-18 23:04:26UTCMore templates
- tanstack-router-solid-example-basic
- tanstack-router-solid-example-basic-devtools-panel
- tanstack-router-solid-example-basic-file-based
- tanstack-router-solid-example-basic-non-nested-devtools
- tanstack-router-solid-example-basic-solid-query
- tanstack-router-solid-example-basic-solid-query-file-based
- tanstack-router-solid-example-basic-ssr-streaming-file-based
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-solid-start-example-bare
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-static
- tanstack-router-react-example-authenticated-routes
- tanstack-router-react-example-authenticated-routes-firebase
- tanstack-router-react-example-basic
- tanstack-router-react-example-basic-default-search-params
- tanstack-router-react-example-basic-devtools-panel
- tanstack-router-react-example-basic-file-based
- tanstack-router-react-example-basic-non-nested-devtools
- tanstack-router-react-example-react-query
- tanstack-router-react-example-basic-react-query-file-based
- tanstack-router-react-example-basic-ssr-file-based
- tanstack-router-react-example-basic-ssr-streaming-file-based
- tanstack-router-react-example-basic-virtual-file-based
- tanstack-router-react-example-basic-virtual-inside-file-based
- tanstack-router-react-example-deferred-data
- tanstack-router-react-example-kitchen-sink
- tanstack-router-react-example-kitchen-sink-file-based
- tanstack-router-react-example-kitchen-sink-react-query
- tanstack-router-react-example-kitchen-sink-react-query-file-based
- tanstack-router-react-example-large-file-based
- tanstack-router-react-example-location-masking
- tanstack-router-react-example-navigation-blocking
- tanstack-router-react-example-quickstart
- tanstack-router-react-example-quickstart-esbuild-file-based
- tanstack-router-react-example-quickstart-file-based
- tanstack-router-react-example-quickstart-rspack-file-based
- tanstack-router-react-example-quickstart-webpack-file-based
- router-monorepo-react-query
- router-mono-simple
- router-mono-simple-lazy
- tanstack-router-react-example-scroll-restoration
- tanstack-search-validator-adapters
- tanstack-start-example-bare
- tanstack-start-example-basic
- tanstack-start-example-basic-auth
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-rsc
- tanstack-start-example-basic-static
- tanstack-start-example-clerk-basic
- tanstack-start-example-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-example-large
- tanstack-start-example-material-ui
- tanstack-start-example-supabase-basic
- tanstack-start-tailwind-v4
- tanstack-start-example-trellaux
- tanstack-start-example-workos
- tanstack-router-react-example-view-transitions
- tanstack-router-react-example-with-framer-motion
- tanstack-router-react-example-with-trpc
- tanstack-router-react-example-with-trpc-react-query
@tanstack/arktype-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5169@tanstack/directive-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5169@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5169@tanstack/history
npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5169@tanstack/react-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5169@tanstack/react-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5169@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5169@tanstack/react-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5169@tanstack/react-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5169@tanstack/react-start-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-plugin@5169@tanstack/react-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5169@tanstack/router-cli
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5169@tanstack/router-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5169@tanstack/router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5169@tanstack/router-devtools-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5169@tanstack/router-generator
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5169@tanstack/router-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5169@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5169@tanstack/router-utils
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5169@tanstack/router-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5169@tanstack/server-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5169@tanstack/solid-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5169@tanstack/solid-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5169@tanstack/solid-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5169@tanstack/solid-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5169@tanstack/solid-start-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-plugin@5169@tanstack/solid-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5169@tanstack/start-client-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5169@tanstack/start-plugin-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5169@tanstack/start-server-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5169@tanstack/start-server-functions-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-functions-client@5169@tanstack/start-server-functions-fetcher
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-functions-fetcher@5169@tanstack/start-server-functions-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-functions-server@5169@tanstack/start-storage-context
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5169@tanstack/valibot-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5169@tanstack/virtual-file-routes
npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5169@tanstack/zod-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5169commit:
0fa77f0Actionable comments posted: 0
🧹 Nitpick comments (3)
e2e/solid-router/basic-file-based/tests/app.spec.ts (1)
300-333: Avoid unnecessary awaits on Locators and prefer hidden over viewport checksgetByTestIdreturns a Locator;awaitis unnecessary. For the negative checks,toBeHiddenis less flaky thannot.toBeInViewport().Apply this diff:
- const bazIdLink = await page.getByTestId('l-to-non-nested-bazid') - const bazIdEditLink = await page.getByTestId('l-to-non-nested-bazid-edit') + const bazIdLink = page.getByTestId('l-to-non-nested-bazid') + const bazIdEditLink = page.getByTestId('l-to-non-nested-bazid-edit') @@ - await expect(bazHeading).not.toBeInViewport() - await expect(bazIdHeading).not.toBeInViewport() + await expect(bazHeading).toBeHidden() + await expect(bazIdHeading).toBeHidden()e2e/solid-router/basic-file-based/src/routes/non-nested/route.tsx (1)
14-31: Consider using consistent structure for links.The two links render within the same
<li>element without separation. Consider placing each link in its own list item or adding appropriate styling/separation between them.Consider this improved structure:
<ul class="grid mb-2"> <li> <Link from={Route.fullPath} data-testid="l-to-non-nested-bazid" to="./baz/$bazid" params={{ bazid: '123' }} > /non-nested/baz/123 </Link> + </li> + <li> <Link from={Route.fullPath} data-testid="l-to-non-nested-bazid-edit" to="./baz/$bazid/edit" params={{ bazid: '456' }} > /non-nested/baz/456/edit </Link> </li> </ul>packages/router-core/tests/path.test.ts (1)
1542-1562: Consider adding more edge cases for missing splat params.While the test cases cover basic scenarios with prefix/suffix, consider adding edge cases like empty paths or paths with multiple segments after the splat.
Consider adding these test cases:
{ name: 'nested splat route without _splat', path: '/hello/world/$_', params: {}, expectedResult: '/hello/world', }, { name: 'splat route with multiple prefixes', path: '/hello/prefix1{$}prefix2_', params: {}, expectedResult: '/hello/prefix1prefix2', },📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 3b69de0f41e007460d9376fda6a0066c1867b4d8 and 6d164b741635bfc3fb2e6e379701150ec98a4547.
📒 Files selected for processing (16)
e2e/react-router/basic-file-based/src/routeTree.gen.ts(39 hunks)e2e/react-router/basic-file-based/src/routes/non-nested/baz.$bazid.tsx(1 hunks)e2e/react-router/basic-file-based/src/routes/non-nested/baz.tsx(1 hunks)e2e/react-router/basic-file-based/src/routes/non-nested/baz_.$bazid.edit.tsx(1 hunks)e2e/react-router/basic-file-based/src/routes/non-nested/route.tsx(1 hunks)e2e/react-router/basic-file-based/tests/app.spec.ts(1 hunks)e2e/solid-router/basic-file-based/src/routeTree.gen.ts(39 hunks)e2e/solid-router/basic-file-based/src/routes/non-nested/baz.$bazid.tsx(1 hunks)e2e/solid-router/basic-file-based/src/routes/non-nested/baz.tsx(1 hunks)e2e/solid-router/basic-file-based/src/routes/non-nested/baz_.$bazid.edit.tsx(1 hunks)e2e/solid-router/basic-file-based/src/routes/non-nested/route.tsx(1 hunks)e2e/solid-router/basic-file-based/tests/app.spec.ts(1 hunks)e2e/solid-router/basic-file-based/tests/redirect.spec.ts(1 hunks)packages/router-core/src/path.ts(1 hunks)packages/router-core/tests/match-by-path.test.ts(1 hunks)packages/router-core/tests/path.test.ts(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (9)
e2e/react-router/basic-file-based/src/routes/non-nested/baz.$bazid.tsx (3)
e2e/react-router/basic-file-based/src/routes/non-nested/baz.tsx (1)
Route(3-5)
e2e/react-router/basic-file-based/src/routes/non-nested/baz_.$bazid.edit.tsx (1)
Route(3-5)
e2e/react-router/basic-file-based/src/routes/non-nested/route.tsx (1)
Route(3-5)
e2e/react-router/basic-file-based/src/routes/non-nested/baz.tsx (3)
e2e/react-router/basic-file-based/src/routes/non-nested/baz.$bazid.tsx (1)
Route(3-5)
e2e/react-router/basic-file-based/src/routes/non-nested/baz_.$bazid.edit.tsx (1)
Route(3-5)
e2e/react-router/basic-file-based/src/routes/non-nested/route.tsx (1)
Route(3-5)
e2e/solid-router/basic-file-based/src/routes/non-nested/baz_.$bazid.edit.tsx (3)
e2e/solid-router/basic-file-based/src/routes/non-nested/baz.$bazid.tsx (1)
Route(3-5)
e2e/solid-router/basic-file-based/src/routes/non-nested/baz.tsx (1)
Route(3-5)
e2e/solid-router/basic-file-based/src/routes/non-nested/route.tsx (1)
Route(3-5)
e2e/react-router/basic-file-based/src/routes/non-nested/baz_.$bazid.edit.tsx (3)
e2e/react-router/basic-file-based/src/routes/non-nested/baz.$bazid.tsx (1)
Route(3-5)
e2e/react-router/basic-file-based/src/routes/non-nested/baz.tsx (1)
Route(3-5)
e2e/react-router/basic-file-based/src/routes/non-nested/route.tsx (1)
Route(3-5)
e2e/react-router/basic-file-based/src/routes/non-nested/route.tsx (3)
e2e/react-router/basic-file-based/src/routes/non-nested/baz.$bazid.tsx (1)
Route(3-5)
e2e/react-router/basic-file-based/src/routes/non-nested/baz.tsx (1)
Route(3-5)
e2e/react-router/basic-file-based/src/routes/non-nested/baz_.$bazid.edit.tsx (1)
Route(3-5)
e2e/solid-router/basic-file-based/src/routes/non-nested/route.tsx (3)
e2e/solid-router/basic-file-based/src/routes/non-nested/baz.$bazid.tsx (1)
Route(3-5)
e2e/solid-router/basic-file-based/src/routes/non-nested/baz.tsx (1)
Route(3-5)
e2e/solid-router/basic-file-based/src/routes/non-nested/baz_.$bazid.edit.tsx (1)
Route(3-5)
e2e/solid-router/basic-file-based/src/routes/non-nested/baz.$bazid.tsx (3)
e2e/solid-router/basic-file-based/src/routes/non-nested/baz.tsx (1)
Route(3-5)
e2e/solid-router/basic-file-based/src/routes/non-nested/baz_.$bazid.edit.tsx (1)
Route(3-5)
e2e/solid-router/basic-file-based/src/routes/non-nested/route.tsx (1)
Route(3-5)
e2e/solid-router/basic-file-based/src/routes/non-nested/baz.tsx (3)
e2e/solid-router/basic-file-based/src/routes/non-nested/baz.$bazid.tsx (1)
Route(3-5)
e2e/solid-router/basic-file-based/src/routes/non-nested/baz_.$bazid.edit.tsx (1)
Route(3-5)
e2e/solid-router/basic-file-based/src/routes/non-nested/route.tsx (1)
Route(3-5)
packages/router-core/tests/path.test.ts (1)
packages/router-core/src/path.ts (8)
resolvePath(153-206)trimPathLeft(39-41)interpolatePath(375-489)matchPathname(501-520)SEGMENT_TYPE_PATHNAME(6-6)SEGMENT_TYPE_PARAM(7-7)SEGMENT_TYPE_WILDCARD(8-8)parsePathname(209-219)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Preview
- GitHub Check: Test
🔇 Additional comments (18)
packages/router-core/src/path.ts (1)
336-345: Correct: decode normalized segment to honor non-nested markerDecoding
partToMatch(post underscore-strip) fixes mismatches for segments likebaz_. Please add a couple of regression cases:'/non-nested/baz_/$id'vs actual url/non-nested/baz/123- segment containing
%25plus trailing_, e.g.'abc%25def_'→'abc%25def'
e2e/react-router/basic-file-based/src/routes/non-nested/baz.$bazid.tsx (1)
7-23: LGTM: dynamic params surfaced with stable test idsComponent is minimal and test-friendly. No issues.
e2e/react-router/basic-file-based/src/routes/non-nested/baz_.$bazid.edit.tsx (1)
7-21: LGTM: edit route wiring matches testsRoute path and test ids align with the new e2e assertions.
e2e/react-router/basic-file-based/src/routes/non-nested/baz.tsx (1)
7-14: LGTM: parent outlet for non-nested branchParent heading + Outlet behaves as expected for
/non-nested/bazand not for the edit branch.e2e/solid-router/basic-file-based/src/routes/non-nested/baz.tsx (1)
7-14: LGTM: Solid parent with Outlet mirrors React variantParity maintained with React route; good for cross-framework tests.
e2e/solid-router/basic-file-based/tests/redirect.spec.ts (1)
58-59: Good flake fix: wait for network idle after raceThe extra
waitForLoadState('networkidle')stabilizes preload detection before assertions and navigation.e2e/react-router/basic-file-based/src/routes/non-nested/route.tsx (1)
13-35: LGTM: links generated from Route.fullPath; paths align with non-nested behaviorRelative
totargets are clean (no_in URL) and match the updated parsing.packages/router-core/tests/match-by-path.test.ts (1)
201-388: LGTM!The new test suite for non-nested paths comprehensively covers regular path matching, case insensitive matching, and fuzzy matching scenarios, extending the test coverage systematically with wildcard, optional parameter, and static path variations.
e2e/solid-router/basic-file-based/src/routes/non-nested/baz_.$bazid.edit.tsx (1)
1-22: LGTM!The implementation correctly defines the non-nested edit route for Solid Router with appropriate parameter extraction and rendering. The test IDs align well with the test assertions in the app.spec.ts file.
e2e/solid-router/basic-file-based/src/routes/non-nested/baz.$bazid.tsx (1)
1-23: LGTM!The route component follows the expected pattern for dynamic parameter routes in Solid Router, correctly extracting and rendering the
bazidparameter with appropriate test IDs.e2e/react-router/basic-file-based/src/routeTree.gen.ts (3)
24-77: LGTM!The import statements for the new non-nested routes are correctly added and follow the existing naming conventions.
141-201: LGTM!The route definitions for non-nested paths are correctly configured with appropriate parent-child relationships, IDs, and paths.
1424-1448: LGTM!The route hierarchy for NonNestedBazRoute and its children is correctly established, following the expected pattern for nested routes.
e2e/react-router/basic-file-based/tests/app.spec.ts (1)
312-345: LGTM!The end-to-end test thoroughly validates the non-nested path behavior, checking navigation, visibility of components, and correct parameter rendering at each route level.
packages/router-core/tests/path.test.ts (1)
1129-2110: Comprehensive test coverage for non-nested paths!The test suite provides excellent coverage for non-nested paths across all major path operation functions (resolvePath, interpolatePath, matchPathname, parsePathname). The tests thoroughly validate trailing underscore stripping behavior, parameter extraction, and path resolution with various configurations.
e2e/solid-router/basic-file-based/src/routeTree.gen.ts (3)
23-68: LGTM!The import statements for the new non-nested routes correctly follow the existing patterns and naming conventions.
126-180: LGTM!The route definitions are correctly configured with appropriate IDs, paths, and parent relationships matching the expected non-nested structure.
1238-1262: LGTM!The route hierarchy correctly establishes the parent-child relationships for the non-nested routes, matching the structure in the React Router implementation.
nlynzaad(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Walkthrough#
Adds non-nested route examples to React and Solid E2E apps (/non-nested, /non-nested/baz, dynamic $bazid, and edit variants), updates generated route trees and tests, adjusts router-core path parsing for non-nested segments, and expands router-core tests for matching and path resolution in non-nested scenarios.
Changes#
e2e/react-router/basic-file-based/src/routeTree.gen.ts,e2e/react-router/basic-file-based/src/routes/non-nested/route.tsx,e2e/react-router/basic-file-based/src/routes/non-nested/baz.tsx,e2e/react-router/basic-file-based/src/routes/non-nested/baz.$bazid.tsx,e2e/react-router/basic-file-based/src/routes/non-nested/baz_.$bazid.edit.tsxe2e/react-router/basic-file-based/tests/app.spec.tse2e/solid-router/basic-file-based/src/routeTree.gen.ts,e2e/solid-router/basic-file-based/src/routes/non-nested/route.tsx,e2e/solid-router/basic-file-based/src/routes/non-nested/baz.tsx,e2e/solid-router/basic-file-based/src/routes/non-nested/baz.$bazid.tsx,e2e/solid-router/basic-file-based/src/routes/non-nested/baz_.$bazid.edit.tsxe2e/solid-router/basic-file-based/tests/app.spec.ts,e2e/solid-router/basic-file-based/tests/redirect.spec.tspackages/router-core/src/path.tspackages/router-core/tests/match-by-path.test.ts,packages/router-core/tests/path.test.tsSequence Diagram(s)#
Estimated code review effort#
🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs#
Suggested labels#
package: react-router,package: solid-routerSuggested reviewers#
Poem#
Pre-merge checks and finishing touches#
❌ Failed checks (1 warning)
@coderabbitai generate docstringsto improve docstring coverage.✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 6d164b741635bfc3fb2e6e379701150ec98a4547 and 0fa77f03c08f87fed5ce2b6425e4a46fba486a1f.
📒 Files selected for processing (4)
e2e/react-router/basic-file-based/src/routes/non-nested/route.tsx(1 hunks)e2e/react-router/basic-file-based/tests/app.spec.ts(1 hunks)e2e/solid-router/basic-file-based/src/routes/non-nested/route.tsx(1 hunks)e2e/solid-router/basic-file-based/tests/app.spec.ts(1 hunks)🚧 Files skipped from review as they are similar to previous changes (4)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Comment `@coderabbitai help` to get the list of available commands and usage tips.