@@ -150,12 +150,6 @@ export function defineParamParser<TOut, TIn extends string | string[]>(parser: {
150
150
return parser
151
151
}
152
152
153
- interface IdFn {
154
- ( v : undefined | null ) : null
155
- ( v : string ) : string
156
- ( v : string [ ] ) : string [ ]
157
- }
158
-
159
153
const PATH_PARAM_DEFAULT_GET = ( value : string | string [ ] | null | undefined ) =>
160
154
value ?? null
161
155
export const PATH_PARAM_SINGLE_DEFAULT : Param_GetSet < string , string > = { }
@@ -344,52 +338,6 @@ export class MatcherPatternPathCustomParams<
344
338
}
345
339
}
346
340
347
- const aaa = new MatcherPatternPathCustomParams (
348
- / ^ \/ p r o f i l e s \/ ( [ ^ / ] + ) $ / i,
349
- {
350
- userId : {
351
- parser : PARAM_INTEGER ,
352
- // parser: PATH_PARAM_DEFAULT_PARSER,
353
- } ,
354
- } ,
355
- [ 'profiles' , 0 ]
356
- )
357
- // @ts -expect-error: not existing param
358
- aaa . build ( { a : '2' } )
359
- // @ts -expect-error: must be a number
360
- aaa . build ( { userId : '2' } )
361
- aaa . build ( { userId : 2 } )
362
- // @ts -expect-error: not existing param
363
- aaa . match ( '/profiles/2' ) ?. e
364
- // @ts -expect-error: not existing param
365
- aaa . match ( '/profiles/2' ) . e
366
- aaa . match ( '/profiles/2' ) . userId . toFixed ( 2 )
367
-
368
- // Factory function for better type inference
369
- export function createMatcherPatternPathCustomParams <
370
- TParamsOptions extends Record <
371
- string ,
372
- MatcherPatternPathCustomParamOptions < any , any >
373
- > ,
374
- > (
375
- re : RegExp ,
376
- params : TParamsOptions ,
377
- pathParts : Array < string | number >
378
- ) : MatcherPatternPathCustomParams < TParamsOptions > {
379
- return new MatcherPatternPathCustomParams ( re , params , pathParts )
380
- }
381
-
382
- // Now use it like this:
383
- const aab = createMatcherPatternPathCustomParams (
384
- / ^ \/ p r o f i l e s \/ ( [ ^ / ] + ) $ / i,
385
- {
386
- userId : {
387
- parser : PARAM_INTEGER ,
388
- } ,
389
- } ,
390
- [ 'profiles' , 0 ]
391
- )
392
-
393
341
/**
394
342
* Matcher for dynamic paths, e.g. `/team/:id/:name`.
395
343
* Supports one, one or zero, one or more and zero or more params.
0 commit comments