@contrast/route-coverage 1.40.0 → 1.41.0

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.
@@ -109,13 +109,13 @@ module.exports = function init(core) {
109
109
  */
110
110
  [
111
111
  { version: '>=3 <4.1.0', routeObj: false },
112
- { version: '>=4.1.0 <4.4.0', routeObj: true },
113
- { version: '>=4.4.0 <5', routeObj: true }
112
+ { version: '>=4.1.0 <6', routeObj: true },
114
113
  ].forEach(({ version, routeObj }) => {
115
114
  // See ../utils/methods
116
115
  // Using .all shorthand uses all valid methods but those change after version 4.4.0
117
- const FASTIFY_METHODS = getFastifyMethods(version);
118
- depHooks.resolve({ name: 'fastify', version, file: 'lib/route.js' }, (Route) => {
116
+ depHooks.resolve({ name: 'fastify', version, file: 'lib/route.js' }, (Route, metadata) => {
117
+ const fastifyMethods = getFastifyMethods(metadata.version);
118
+
119
119
  patcher.patch(Route, 'buildRouting', {
120
120
  name: 'fastify.Route.buildRouting',
121
121
  patchType,
@@ -144,7 +144,7 @@ module.exports = function init(core) {
144
144
  let handle = 'handler';
145
145
  if (!handler && typeof options === 'function') handle = 'options';
146
146
 
147
- discoverAndPatch(method, path, routeObj ? data.args[0] : data.args, handle, FASTIFY_METHODS, false);
147
+ discoverAndPatch(method, path, routeObj ? data.args[0] : data.args, handle, fastifyMethods, false);
148
148
  }
149
149
  });
150
150
 
@@ -161,7 +161,7 @@ module.exports = function init(core) {
161
161
 
162
162
  const prefix = getPrefix(data.obj);
163
163
  const path = prefix ? prefix + url : url;
164
- discoverAndPatch(method, path, routeArgs, 'handler', FASTIFY_METHODS, true);
164
+ discoverAndPatch(method, path, routeArgs, 'handler', fastifyMethods, true);
165
165
  }
166
166
  });
167
167
  }
@@ -17,7 +17,7 @@
17
17
  const semver = require('semver');
18
18
  const { METHODS } = require('http');
19
19
 
20
- function getFastifyMethods(range) {
20
+ function getFastifyMethods(version) {
21
21
  return [
22
22
  'DELETE',
23
23
  'GET',
@@ -26,7 +26,7 @@ function getFastifyMethods(range) {
26
26
  'POST',
27
27
  'PUT',
28
28
  'OPTIONS',
29
- ...semver.subset(range, '>=4.4.0') ?
29
+ ...semver.satisfies(version, '>=4.4.0 <5') ?
30
30
  [
31
31
  'PROPFIND',
32
32
  'PROPPATCH',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/route-coverage",
3
- "version": "1.40.0",
3
+ "version": "1.41.0",
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)",