delvedor/find-my-way

Issue in parameter resolution

fxalgrain opened this issue · 5 comments

Hi,

I m using my find-my-way via Fastify and I m facing an issue parametrics url.

I defined a route like that : GET /images/:id.jpg
When I make this request GET /images/123456.jpg it works as expected but when I make this one : GET /images/12346-fr.jpg
It's does not work.

I think the issue is linked to the support of multi params

Hi, IMHO, it shouldn't be a multiparametric node since there is only one param in your URL.

I think the problem should be where it defines it as a multiparametric route.

nodeType = NODE_TYPES.MULTI_PARAM

Yes it sounds a bit strange. As I understand the . is defined as a splitter.
Made a change looks me risky.

I think if we change this behavior , the .jpg will not be excluded from param value

As suggested by @bugagashenkj, a valid workaround is to use a regex route like this :

router.on('GET', '/example/:file(^\\d+).png', () => {}))