Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addLeadingSlash shoudl not add leading slash for optional parameter #14545

Closed
4 of 15 tasks
dcharbonnier opened this issue Jan 31, 2025 · 5 comments
Closed
4 of 15 tasks
Labels
needs triage This issue has not been looked into

Comments

@dcharbonnier
Copy link
Contributor

dcharbonnier commented Jan 31, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Due to recent route change addLeadingSlash fail to detect leading slash
The path @Get('{/:optional}/test.js') is now mapped to /{/:optional}/test.js this fail to match the path
/test.js the leading slash is present but optional.
I can make a PR for this issue but this looks dependant of the adapter so it may break fastify.
pillarjs/path-to-regexp#344 (reply in thread)

Minimum reproduction code

https://codesandbox.io/p/devbox/sharp-gould-8xyrf9?file=%2Fsrc%2Fapp.controller.ts

Steps to reproduce

No response

Expected behavior

/fail2.js ans /test/fail2.js should both work

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

No response

NestJS version

No response

Packages versions

│ ├── @nestjs/common@11.0.6
│ ├── @nestjs/core@11.0.6
│ ├── @nestjs/event-emitter@3.0.0
│ ├── @nestjs/microservices@11.0.6
│ ├── @nestjs/platform-express@11.0.6
│ ├── @nestjs/schematics@11.0.0
│ ├── @nestjs/testing@11.0.6

Node.js version

No response

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@dcharbonnier dcharbonnier added the needs triage This issue has not been looked into label Jan 31, 2025
@kamilmysliwiec
Copy link
Member

Not sure if I'm following. What's wrong with:

@Get(['test.js', '{*segment}/test.js'])

?

@dcharbonnier
Copy link
Contributor Author

dcharbonnier commented Feb 1, 2025 via email

@kamilmysliwiec
Copy link
Member

Could you share an example?

@dcharbonnier
Copy link
Contributor Author

@kamilmysliwiec
Copy link
Member

Let's track this here #14546

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

2 participants