@@ -5,7 +5,12 @@ import {
5
5
parsePathname ,
6
6
processRouteTree ,
7
7
} from '../src'
8
- import { SEGMENT_TYPE_OPTIONAL_PARAM , SEGMENT_TYPE_PARAM , SEGMENT_TYPE_PATHNAME , SEGMENT_TYPE_WILDCARD } from "../src/path"
8
+ import {
9
+ SEGMENT_TYPE_OPTIONAL_PARAM ,
10
+ SEGMENT_TYPE_PARAM ,
11
+ SEGMENT_TYPE_PATHNAME ,
12
+ SEGMENT_TYPE_WILDCARD ,
13
+ } from '../src/path'
9
14
10
15
interface TestRoute {
11
16
id : string
@@ -170,7 +175,10 @@ describe('work in progress', () => {
170
175
let fn = 'const baseSegments = parsePathname(from);'
171
176
fn += '\nconst l = baseSegments.length;'
172
177
173
- type ParsedRoute = { path : string , segments : ReturnType < typeof parsePathname > }
178
+ type ParsedRoute = {
179
+ path : string
180
+ segments : ReturnType < typeof parsePathname >
181
+ }
174
182
175
183
function recursiveStaticMatch (
176
184
parsedRoutes : Array < ParsedRoute > ,
@@ -181,19 +189,14 @@ describe('work in progress', () => {
181
189
for ( const route of parsedRoutes ) {
182
190
if ( resolved . has ( route ) ) continue // already resolved
183
191
console . log ( '\n' )
184
- console . log (
185
- 'resolving: depth=' ,
186
- depth ,
187
- 'parsed=' ,
188
- route . path ,
189
- )
192
+ console . log ( 'resolving: depth=' , depth , 'parsed=' , route . path )
190
193
console . log ( '\u001b[34m' + fn + '\u001b[0m' )
191
194
const currentSegment = route . segments [ depth ]
192
195
if ( ! currentSegment ) {
193
196
throw new Error (
194
197
'Implementation error: this should not happen, depth=' +
195
- depth +
196
- `, route=${ route . path } ` ,
198
+ depth +
199
+ `, route=${ route . path } ` ,
197
200
)
198
201
}
199
202
const candidates = parsedRoutes . filter ( ( r ) => {
@@ -227,7 +230,10 @@ describe('work in progress', () => {
227
230
rParsed . suffixSegment === currentSegment . suffixSegment
228
231
)
229
232
} )
230
- console . log ( 'candidates:' , candidates . map ( r => r . path ) )
233
+ console . log (
234
+ 'candidates:' ,
235
+ candidates . map ( ( r ) => r . path ) ,
236
+ )
231
237
if ( candidates . length === 0 ) {
232
238
throw new Error ( 'Implementation error: this should not happen' )
233
239
}
@@ -321,7 +327,9 @@ describe('work in progress', () => {
321
327
const leaf = candidates [ 0 ] !
322
328
323
329
// Check if this route contains a wildcard segment
324
- const wildcardIndex = leaf . segments . findIndex ( ( s ) => s && s . type === SEGMENT_TYPE_WILDCARD )
330
+ const wildcardIndex = leaf . segments . findIndex (
331
+ ( s ) => s && s . type === SEGMENT_TYPE_WILDCARD ,
332
+ )
325
333
326
334
if ( wildcardIndex !== - 1 && wildcardIndex >= depth ) {
327
335
// This route has a wildcard at or after the current depth
@@ -642,6 +650,7 @@ describe('work in progress', () => {
642
650
'/images/thumb_200x300.jpg' ,
643
651
'/logs/error.txt' ,
644
652
'/cache/temp_user456.log' ,
653
+ '/a/b/c/d/e' ,
645
654
] ) ( 'matching %s' , ( s ) => {
646
655
const originalMatch = originalMatcher ( s )
647
656
const buildMatch = buildMatcher ( parsePathname , s )
0 commit comments