Repository navigation
fix(core): normalize slashes when mapping controllers for middleware - #18075
Merged
kamilmysliwiec merged 1 commit intoOct 12, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
This is the standalone
RoutesMapperfix mentioned as point 4 in the review of #18023.When middleware is bound with
forRoutes(SomeController),RoutesMapperbuilds each path by concatenating the module path, the controller path and the method path as they are. The router builds the same routes with trailing slashes stripped at every join, so the two disagree whenever a segment ends in a slash, and the middleware silently never runs for the route it was bound to. The route itself still answers, so nothing visibly fails.Two ordinary setups hit this:
In both cases
consumer.apply(SomeMiddleware).forRoutes(TailController)(orCatsController) has no effect on master.What is the new behavior?
RoutesMapperstrips the trailing slash from the module path and the controller path before joining them, the same wayRoutePathFactorydoes for the routes, so the middleware path matches the registered route again.Does this PR introduce a breaking change?
Other information
Unit tests in
routes-mapper.spec.tscover a controller path ending in a slash, a module path of/, and the two combined. The newmiddleware-controller-path.spec.tse2e spec reproduces both setups above plus a controller path ending in a slash under aRouterModulepath. All three e2e cases fail on master (the handler answers instead of the middleware) and pass with this change.