@contrast/route-coverage 1.20.0 → 1.20.1

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.
@@ -103,13 +103,16 @@ module.exports = function init(core) {
103
103
  const fn = args[len - 1];
104
104
  const path = len > 1 ? args[0] : '';
105
105
  if (!isValidPath(path)) return;
106
- if (isRouter(fn)) {
107
- traverse(path, fn.stack);
108
- } else {
109
- const routeInfo = createRouteInfo(path, 'use', 'App');
110
- discover(routeInfo);
111
- patchHandle(result._router, routeInfo);
112
- }
106
+ const handlers = Array.isArray(fn) ? fn : [fn];
107
+ handlers.forEach((layer) => {
108
+ if (isRouter(layer)) {
109
+ traverse(path, layer.stack);
110
+ } else {
111
+ const routeInfo = createRouteInfo(format(path), 'use', 'App');
112
+ discover(routeInfo);
113
+ patchHandle(result._router, routeInfo);
114
+ }
115
+ });
113
116
  }
114
117
  });
115
118
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/route-coverage",
3
- "version": "1.20.0",
3
+ "version": "1.20.1",
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)",