const pattern = new MatcherPatternPathCustomParams(
/^\/teams(?:\/([^/]+?))?\/b$/i,
{
- teamId: { optional: true },
+ teamId: {},
},
['teams', 0, 'b']
)
const pattern = new MatcherPatternPathCustomParams(
/^\/teams(?:\/(.+?))?\/b$/i,
{
- teamId: { repeat: true, optional: true },
+ teamId: { repeat: true },
},
['teams', 0, 'b']
)
interface MatcherPatternPathCustomParamOptions<
TIn extends string | string[] | null = string | string[] | null,
TOut = string | string[] | null,
-> {
+> extends Param_GetSet<TIn, TOut> {
repeat?: boolean
- // TODO: not needed because in the regexp, the value is undefined if the group is optional and not given
- optional?: boolean
- parser?: Param_GetSet<TIn, TOut>
+ // NOTE: not needed because in the regexp, the value is undefined if
+ // the group is optional and not given
+ // optional?: boolean
}
/**
)
: decode(currentMatch)
- params[paramName] = (paramOptions.parser?.get || (v => v))(
+ params[paramName] = (paramOptions.get || (v => v))(
value
// NOTE: paramName and paramOptions are not connected from TS point of view
)
const paramName = this.paramsKeys[paramIndex++]
const paramOptions = this.params[paramName]
const value: ReturnType<NonNullable<Param_GetSet['set']>> = (
- paramOptions.parser?.set || (v => v)
+ paramOptions.set || (v => v)
)(params[paramName])
return Array.isArray(value)