@@ -112,10 +112,7 @@ const allRoutes = new Set<RouteObject>();
112112/**
113113 * Processes resolved routes by adding them to allRoutes and checking for nested async handlers.
114114 */
115- export function processResolvedRoutes (
116- resolvedRoutes : RouteObject [ ] ,
117- parentRoute ?: RouteObject ,
118- currentLocation ?: Location ,
115+ currentLocation: Location | null = null ,
119116) : void {
120117 resolvedRoutes. forEach ( child => {
121118 allRoutes . add ( child ) ;
@@ -137,11 +134,7 @@ export function processResolvedRoutes(
137134
138135 // Try to use the provided location first, then fall back to global window location if needed
139136 let location = currentLocation ;
140- if ( ! location ) {
141- if ( typeof WINDOW !== 'undefined' ) {
142- const globalLocation = WINDOW . location ;
143- if ( globalLocation ) {
144- location = { pathname : globalLocation . pathname } ;
137+ location = createDefaultLocation ( globalLocation . pathname ) ;
145138 }
146139 }
147140 }
@@ -553,9 +546,8 @@ function wrapPatchRoutesOnNavigation(
553546 // Update navigation span after routes are patched
554547 const activeRootSpan = getActiveRootSpan ( ) ;
555548 if ( activeRootSpan && ( spanToJSON ( activeRootSpan ) as { op ?: string } ) . op === 'navigation' ) {
556- // For memory routers, we don't have a reliable way to get the current pathname
557- // without accessing window.location, so we'll use targetPath for both cases
558- const pathname = targetPath || ( isMemoryRouter ? WINDOW . location ?. pathname : undefined ) ;
549+ // For memory routers, we should not access window.location; use targetPath only
550+ const pathname = isMemoryRouter ? targetPath : targetPath || WINDOW . location ?. pathname ;
559551 if ( pathname ) {
560552 updateNavigationSpan (
561553 activeRootSpan ,
0 commit comments