@@ -173,12 +173,12 @@ describe('work in progress', () => {
173
173
indent = '' ,
174
174
) {
175
175
const resolved = new Set < ReturnType < typeof parsePathname > > ( )
176
- for ( const parsed of parsedRoutes ) {
177
- if ( resolved . has ( parsed ) ) continue // already resolved
176
+ for ( const routeSegments of parsedRoutes ) {
177
+ if ( resolved . has ( routeSegments ) ) continue // already resolved
178
178
console . log ( '\n' )
179
- console . log ( 'resolving: depth=' , depth , 'parsed=' , logParsed ( parsed ) )
179
+ console . log ( 'resolving: depth=' , depth , 'parsed=' , logParsed ( routeSegments ) )
180
180
console . log ( '\u001b[34m' + fn + '\u001b[0m' )
181
- const currentSegment = parsed [ depth ]
181
+ const currentSegment = routeSegments [ depth ]
182
182
if ( ! currentSegment ) {
183
183
throw new Error ( 'Implementation error: this should not happen' )
184
184
}
@@ -198,7 +198,7 @@ describe('work in progress', () => {
198
198
throw new Error ( 'Implementation error: this should not happen' )
199
199
}
200
200
if ( candidates . length > 1 ) {
201
- let skipDepth = parsed . slice ( depth + 1 ) . findIndex ( ( s , i ) =>
201
+ let skipDepth = routeSegments . slice ( depth + 1 ) . findIndex ( ( s , i ) =>
202
202
candidates . some ( ( c ) => {
203
203
const segment = c [ depth + 1 + i ]
204
204
return (
@@ -211,21 +211,19 @@ describe('work in progress', () => {
211
211
)
212
212
} ) ,
213
213
)
214
- if ( skipDepth === - 1 ) skipDepth = parsed . length - depth - 1
214
+ if ( skipDepth === - 1 ) skipDepth = routeSegments . length - depth - 1
215
215
const lCondition =
216
216
skipDepth || depth > initialDepth
217
217
? `l > ${ depth + skipDepth } && `
218
218
: ''
219
- const skipConditions = skipDepth
220
- ? `\n${ indent } && ` +
221
- Array . from (
222
- { length : skipDepth } ,
223
- ( _ , i ) =>
224
- `baseSegments[${ depth + 1 + i } ].type === ${ candidates [ 0 ] ! [ depth + 1 + i ] ! . type } && baseSegments[${ depth + 1 + i } ].value === '${ candidates [ 0 ] ! [ depth + 1 + i ] ! . value } '` ,
225
- ) . join ( `\n${ indent } && ` ) +
226
- `\n${ indent } `
227
- : ''
228
- fn += `\n${ indent } if (${ lCondition } baseSegments[${ depth } ].type === ${ parsed [ depth ] ! . type } && baseSegments[${ depth } ].value === '${ parsed [ depth ] ! . value } '${ skipConditions } ) {`
219
+ const skipConditions =
220
+ Array . from (
221
+ { length : skipDepth + 1 } ,
222
+ ( _ , i ) =>
223
+ `baseSegments[${ depth + i } ].type === ${ candidates [ 0 ] ! [ depth + i ] ! . type } && baseSegments[${ depth + i } ].value === '${ candidates [ 0 ] ! [ depth + i ] ! . value } '` ,
224
+ ) . join ( `\n${ indent } && ` ) +
225
+ ( skipDepth ? `\n${ indent } ` : '' )
226
+ fn += `\n${ indent } if (${ lCondition } ${ skipConditions } ) {`
229
227
const deeper = candidates . filter (
230
228
( c ) => c . length > depth + 1 + skipDepth ,
231
229
)
@@ -240,7 +238,7 @@ describe('work in progress', () => {
240
238
}
241
239
if ( leaves . length > 1 ) {
242
240
throw new Error (
243
- `Multiple candidates found for depth ${ depth } with type ${ parsed [ depth ] ! . type } and value ${ parsed [ depth ] ! . value } : ${ leaves . map ( logParsed ) . join ( ', ' ) } ` ,
241
+ `Multiple candidates found for depth ${ depth } with type ${ routeSegments [ depth ] ! . type } and value ${ routeSegments [ depth ] ! . value } : ${ leaves . map ( logParsed ) . join ( ', ' ) } ` ,
244
242
)
245
243
} else if ( leaves . length === 1 ) {
246
244
// WARN: is it ok that the leaf is matched last?
0 commit comments