Skip to content

RouterModule wrongly setting module metadata when child.path is empty string #15332

@gentunian

Description

@gentunian

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

I've created a reproduction example with the readme detailing the issue here: https://github.com/gentunian/nestjs-router-module-bug-children-path-empty-string

TL&DR
The RouterModule won't set the MODULE_PATH metadata correctly to the module being passed when the path is an empty string. Instead, it will set the metadata to an object, that is the { path: '', module: <module> } object.

Minimum reproduction code

https://github.com/gentunian/nestjs-router-module-bug-children-path-empty-string

Steps to reproduce

No response

Expected behavior

It's expected that RouterModule would set the appropriate MODULE_PATH metadata to the module. In this case, the MODULE_PATH would be the flattened one.

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

v11.0.1

Packages versions

Node.js version

v22.15.0

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