Skip to content

addLeadingSlash shoudl not add leading slash for optional parameter #14545

Closed
@dcharbonnier

Description

@dcharbonnier

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue has not been looked into

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions