Optional path not working properly in ElysiaJS

I’m trying to implement an optional path, but it doesn’t seem to work. I have the following:

.get('/api/xxx/:param1/:id?', ({ params: { id } }) => `id ${id}`) 

When id is not defined, so /api/xxx/1234, it returns NOT_FOUND (instead of id undefined). (but /api/xxx/1234/1 works properly)

.get('/api/:id?', ({ params: { id } }) => `id ${id}`)

This works if id is undefined, but it is obviously not what I want. I also want :param1 (and possibly more params)

This seems so basic but I can’t get it to work.