@@ -1209,37 +1209,16 @@ export function resolveTo(
1209
1209
// to the current location's pathname and *not* the route pathname.
1210
1210
if ( toPathname == null ) {
1211
1211
from = locationPathname ;
1212
- } else if ( isPathRelative ) {
1213
- let fromSegments =
1214
- routePathnames . length === 0
1215
- ? [ ]
1216
- : routePathnames [ routePathnames . length - 1 ]
1217
- . replace ( / ^ \/ / , "" )
1218
- . split ( "/" ) ;
1219
-
1220
- if ( toPathname . startsWith ( ".." ) ) {
1221
- let toSegments = toPathname . split ( "/" ) ;
1222
-
1223
- // With relative="path", each leading .. segment means "go up one URL segment"
1224
- while ( toSegments [ 0 ] === ".." ) {
1225
- toSegments . shift ( ) ;
1226
- fromSegments . pop ( ) ;
1227
- }
1228
-
1229
- to . pathname = toSegments . join ( "/" ) ;
1230
- }
1231
-
1232
- from = "/" + fromSegments . join ( "/" ) ;
1233
1212
} else {
1234
1213
let routePathnameIndex = routePathnames . length - 1 ;
1235
1214
1236
- if ( toPathname . startsWith ( ".." ) ) {
1215
+ // With relative="route" (the default), each leading .. segment means
1216
+ // "go up one route" instead of "go up one URL segment". This is a key
1217
+ // difference from how <a href> works and a major reason we call this a
1218
+ // "to" value instead of a "href".
1219
+ if ( ! isPathRelative && toPathname . startsWith ( ".." ) ) {
1237
1220
let toSegments = toPathname . split ( "/" ) ;
1238
1221
1239
- // With relative="route" (the default), each leading .. segment means
1240
- // "go up one route" instead of "go up one URL segment". This is a key
1241
- // difference from how <a href> works and a major reason we call this a
1242
- // "to" value instead of a "href".
1243
1222
while ( toSegments [ 0 ] === ".." ) {
1244
1223
toSegments . shift ( ) ;
1245
1224
routePathnameIndex -= 1 ;
@@ -1248,8 +1227,6 @@ export function resolveTo(
1248
1227
to . pathname = toSegments . join ( "/" ) ;
1249
1228
}
1250
1229
1251
- // If there are more ".." segments than parent routes, resolve relative to
1252
- // the root / URL.
1253
1230
from = routePathnameIndex >= 0 ? routePathnames [ routePathnameIndex ] : "/" ;
1254
1231
}
1255
1232
0 commit comments