Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/one/src/router/interceptRoutes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { RouteNode, SlotConfig } from './Route'
import { matchDynamicName } from './matchers'
import { matchDynamicName, stripGroupSegmentsFromPath } from './matchers'
import { isNative } from '../constants'

// ============================================
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down Expand Up @@ -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 = ''
Expand Down
Loading