])
})
+ it('param custom re followed by param without regex', () => {
+ expect(tokenizePath('/:one(\\d+)/:two')).toEqual([
+ [
+ {
+ type: TokenType.Param,
+ value: 'one',
+ regexp: '\\d+',
+ repeatable: false,
+ optional: false,
+ },
+ ],
+ [
+ {
+ type: TokenType.Param,
+ value: 'two',
+ regexp: '',
+ repeatable: false,
+ optional: false,
+ },
+ ],
+ ])
+ })
+
it('param custom re?', () => {
expect(tokenizePath('/:id(\\d+)?')).toEqual([
[
case TokenizerState.Param:
if (char === '(') {
state = TokenizerState.ParamRegExp
- customRe = ''
} else if (VALID_PARAM_RE.test(char)) {
addCharToBuffer()
} else {
state = TokenizerState.Static
// go back one character if we were not modifying
if (char !== '*' && char !== '?' && char !== '+') i--
+ customRe = ''
break
default: