Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,14 @@ Router.prototype.use = function use (handler) {
// add the middleware
debug('use %o %s', path, fn.name || '<anonymous>')

// Normalize mount path: strip trailing slash for consistent behavior
// with strict sub-routers. req.baseUrl already strips trailing slashes,
// so this keeps mount paths consistent with baseUrl semantics.
// See expressjs/express#2281.
if (typeof path === 'string' && path.length > 1 && path.endsWith('/')) {
path = path.slice(0, -1)
}

const layer = new Layer(path, {
sensitive: this.caseSensitive,
strict: false,
Expand Down