-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2e054e
commit 0265a80
Showing
3 changed files
with
25 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,7 +69,6 @@ module.exports = function generateDocument (baseDocument, router, basePath) { | |
|
||
function iterateStack (path, routeLayer, layer, cb) { | ||
cb(path, routeLayer, layer) | ||
|
||
if (layer.name === 'router') { | ||
layer.handle.stack.forEach(l => { | ||
path = path || '' | ||
|
@@ -113,6 +112,16 @@ function processComplexMatch (thing, keys) { | |
|
||
// https://github.com/expressjs/express/issues/3308#issuecomment-300957572 | ||
function split (thing, keys) { | ||
// In express v5 the router layers regexp ([email protected]) | ||
// has some additional handling for end of lines, remove those | ||
// | ||
// layer.regexp | ||
// v4 ^\\/sub-route\\/?(?=\\/|$) | ||
// v5 ^\\/sub-route(?:\\/(?=$))?(?=\\/|$) | ||
// | ||
// l.regexp | ||
// v4 ^\\/endpoint\\/?$ | ||
// v5 ^\\/endpoint(?:\\/)?$ | ||
if (typeof thing === 'string') { | ||
return thing.split('/') | ||
} else if (thing.fast_slash) { | ||
|
@@ -122,6 +131,8 @@ function split (thing, keys) { | |
.toString() | ||
.replace('\\/?', '') | ||
.replace('(?=\\/|$)', '$') | ||
// Added this line to catch the express v5 case after the v4 part is stripped off | ||
.replace('(?:\\/(?=$))?$', '$') | ||
.match(/^\/\^((?:\\[.*+?^${}()|[\]\\/]|[^.*+?^${}()|[\]\\/])*)\$\//) | ||
return match | ||
? match[1].replace(/\\(.)/g, '$1').split('/') | ||
|
This file contains 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
This file contains 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