From bdce73490cc85fc52ab9cb1019e02f31e7edc9df Mon Sep 17 00:00:00 2001 From: Quan Nguyen Date: Wed, 4 Feb 2026 11:57:21 +0700 Subject: [PATCH] fix(interceptRoutes): strip route groups --- packages/one/src/router/interceptRoutes.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/one/src/router/interceptRoutes.ts b/packages/one/src/router/interceptRoutes.ts index bb2841187..326775661 100644 --- a/packages/one/src/router/interceptRoutes.ts +++ b/packages/one/src/router/interceptRoutes.ts @@ -1,5 +1,5 @@ import type { RouteNode, SlotConfig } from './Route' -import { matchDynamicName } from './matchers' +import { matchDynamicName, stripGroupSegmentsFromPath } from './matchers' import { isNative } from '../constants' // ============================================ @@ -69,6 +69,8 @@ function collectAllLayoutsWithSlots( /** * Get the absolute path for a layout node based on its contextKey. * contextKey is like './app/settings/account/_layout.tsx' + * + * Route groups like (app) and (tabs) are stripped since they don't appear in URLs. */ function getLayoutPath(node: RouteNode): string { // Extract path from contextKey @@ -77,6 +79,9 @@ function getLayoutPath(node: RouteNode): string { .replace(/\/?_layout.*$/, '') // Remove _layout and extension .replace(/^app\/?/, '') // Remove 'app/' prefix + // Strip route groups like (app), (tabs) since they don't appear in URLs + path = stripGroupSegmentsFromPath(path) + // Normalize to absolute path return '/' + path } @@ -250,6 +255,9 @@ function resolveInterceptTargetPath( .replace(/\/?_layout.*$/, '') // Remove _layout and extension (with optional leading /) .replace(/^app\/?/, '') // Remove 'app/' prefix since routes are relative to app dir + // Strip route groups like (app), (tabs) since they don't appear in URLs + layoutPath = stripGroupSegmentsFromPath(layoutPath) + // Normalize: empty string or '/' means root if (!layoutPath || layoutPath === '/') { layoutPath = ''