Skip to content

Commit 7890c3f

Browse files
committed
rename stuff
1 parent 3251741 commit 7890c3f

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

packages/router-core/tests/built.test.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,12 @@ describe('work in progress', () => {
173173
indent = '',
174174
) {
175175
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
178178
console.log('\n')
179-
console.log('resolving: depth=', depth, 'parsed=', logParsed(parsed))
179+
console.log('resolving: depth=', depth, 'parsed=', logParsed(routeSegments))
180180
console.log('\u001b[34m' + fn + '\u001b[0m')
181-
const currentSegment = parsed[depth]
181+
const currentSegment = routeSegments[depth]
182182
if (!currentSegment) {
183183
throw new Error('Implementation error: this should not happen')
184184
}
@@ -198,7 +198,7 @@ describe('work in progress', () => {
198198
throw new Error('Implementation error: this should not happen')
199199
}
200200
if (candidates.length > 1) {
201-
let skipDepth = parsed.slice(depth + 1).findIndex((s, i) =>
201+
let skipDepth = routeSegments.slice(depth + 1).findIndex((s, i) =>
202202
candidates.some((c) => {
203203
const segment = c[depth + 1 + i]
204204
return (
@@ -211,21 +211,19 @@ describe('work in progress', () => {
211211
)
212212
}),
213213
)
214-
if (skipDepth === -1) skipDepth = parsed.length - depth - 1
214+
if (skipDepth === -1) skipDepth = routeSegments.length - depth - 1
215215
const lCondition =
216216
skipDepth || depth > initialDepth
217217
? `l > ${depth + skipDepth} && `
218218
: ''
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}) {`
229227
const deeper = candidates.filter(
230228
(c) => c.length > depth + 1 + skipDepth,
231229
)
@@ -240,7 +238,7 @@ describe('work in progress', () => {
240238
}
241239
if (leaves.length > 1) {
242240
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(', ')}`,
244242
)
245243
} else if (leaves.length === 1) {
246244
// WARN: is it ok that the leaf is matched last?

0 commit comments

Comments
 (0)