@contrast/route-coverage 1.20.1 → 1.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/install/express.js +5 -2
- package/package.json +1 -1
package/lib/install/express.js
CHANGED
|
@@ -41,6 +41,7 @@ module.exports = function init(core) {
|
|
|
41
41
|
const regExpToPath = (regex) => regex?.source?.split('/?')[0].replace(/\\/g, '').replace('^', ''); //TODO: replaceAll when v14 deprecated
|
|
42
42
|
const format = (url) => Array.isArray(url) ? `/[${join(url)}]` : url instanceof RegExp ? `/{${url.toString().slice(1, -1)}}` : url;
|
|
43
43
|
const getHandleMethod = (layer) => fnInspect.funcInfo(layer.__handle)?.file.includes('express-async-errors') ? '__handle' : 'handle';
|
|
44
|
+
const getLastLayer = (router) => router?.stack[router.stack.length - 1];
|
|
44
45
|
|
|
45
46
|
function parseRoute(route) {
|
|
46
47
|
const { path } = route;
|
|
@@ -110,7 +111,8 @@ module.exports = function init(core) {
|
|
|
110
111
|
} else {
|
|
111
112
|
const routeInfo = createRouteInfo(format(path), 'use', 'App');
|
|
112
113
|
discover(routeInfo);
|
|
113
|
-
|
|
114
|
+
const lastLayer = getLastLayer(result._router);
|
|
115
|
+
if (lastLayer) patchHandle(lastLayer, routeInfo);
|
|
114
116
|
}
|
|
115
117
|
});
|
|
116
118
|
}
|
|
@@ -125,7 +127,8 @@ module.exports = function init(core) {
|
|
|
125
127
|
if (!url || !fn || !isValidPath(url)) return;
|
|
126
128
|
const routeInfo = createRouteInfo(format(url), method, 'App');
|
|
127
129
|
discover(routeInfo);
|
|
128
|
-
|
|
130
|
+
const lastLayer = getLastLayer(result._router);
|
|
131
|
+
if (lastLayer) patchHandle(lastLayer, routeInfo);
|
|
129
132
|
}
|
|
130
133
|
});
|
|
131
134
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/route-coverage",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.2",
|
|
4
4
|
"description": "Handles route discovery and observation",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
|