When using NestJS with the fastify adapter and trying to apply a wildcard to a controller route, it does not get picked up as a regex.
Applying the hint from the documentation did not help at all:
WARNING
The fastify package uses the latest version of the path-to-regexp package, which no longer supports wildcard asterisks . Instead, you must use parameters (e.g., (.), :splat*).
What I would like to achieve for my cat controller to match any request call that at least contains /cat in the url. So requests that should hit are:
I can only reach the route on http:localhost:3000/(.*)/cat/ but not on the expected routes above.
However when setting the route to /*/cat/ in the controller it will match any request path also http:localhost:3000/foo/bar. For this usecase any routes matches because the wildcard is at the start of the route handler, but it does not respect, that the route should at least have cat in the request path.
I've provided a minimal reproducable stackblitz env for this: Stackblitz
Is there an existing issue for this?
Current behavior
When using NestJS with the fastify adapter and trying to apply a wildcard to a controller route, it does not get picked up as a regex. Applying the hint from the documentation did not help at all:
What I would like to achieve for my cat controller to match any request call that at least contains /cat in the url. So requests that should hit are:
http:localhost:3000/foo/bar/cat
http:localhost:3000/cat
http:localhost:3000/foo-bar/cat
By doing something like this:
http:localhost:3000/(.*)/cat/
but not on the expected routes above./*/cat/
in the controller it will match any request path alsohttp:localhost:3000/foo/bar
. For this usecase any routes matches because the wildcard is at the start of the route handler, but it does not respect, that the route should at least havecat
in the request path.I've provided a minimal reproducable stackblitz env for this: Stackblitz
Minimum reproduction code
https://stackblitz.com/edit/nestjs-starter-demo-qkygfu?file=src/cat.controller.ts
Steps to reproduce
No response
Expected behavior
The expected behaviour is that the wildcard logic should apply for the given controllers.
Package
Other package
No response
NestJS version
8.26
Packages versions
Node.js version
14.14
In which operating systems have you tested?
Other
No response