fetch-mock
Advanced tools
Comparing version 7.2.8 to 7.3.0
@@ -118,4 +118,8 @@ 'use strict'; | ||
var getFunctionMatcher = function getFunctionMatcher(_ref8) { | ||
var matcher = _ref8.matcher; | ||
return typeof matcher === 'function' && matcher; | ||
var matcher = _ref8.matcher, | ||
_ref8$functionMatcher = _ref8.functionMatcher, | ||
functionMatcher = _ref8$functionMatcher === undefined ? function () { | ||
return true; | ||
} : _ref8$functionMatcher; | ||
return typeof matcher === 'function' ? matcher : functionMatcher; | ||
}; | ||
@@ -128,2 +132,8 @@ | ||
if (typeof matcher === 'function') { | ||
return function () { | ||
return true; | ||
}; | ||
} | ||
if (matcher instanceof RegExp) { | ||
@@ -166,3 +176,3 @@ return function (url) { | ||
module.exports = function (route) { | ||
var matchers = [route.query && getQueryStringMatcher(route), route.method && getMethodMatcher(route), route.headers && getHeaderMatcher(route), route.params && getParamsMatcher(route), getFunctionMatcher(route) || getUrlMatcher(route)].filter(function (matcher) { | ||
var matchers = [route.query && getQueryStringMatcher(route), route.method && getMethodMatcher(route), route.headers && getHeaderMatcher(route), route.params && getParamsMatcher(route), getFunctionMatcher(route), getUrlMatcher(route)].filter(function (matcher) { | ||
return !!matcher; | ||
@@ -169,0 +179,0 @@ }); |
{ | ||
"name": "fetch-mock", | ||
"version": "7.2.8", | ||
"version": "7.3.0", | ||
"description": "Mock http requests made using fetch (or isomorphic-fetch)", | ||
@@ -5,0 +5,0 @@ "main": "src/server.js", |
@@ -72,4 +72,4 @@ const glob = require('glob-to-regexp'); | ||
const getFunctionMatcher = ({ matcher }) => | ||
typeof matcher === 'function' && matcher; | ||
const getFunctionMatcher = ({ matcher, functionMatcher = () => true }) => | ||
typeof matcher === 'function' ? matcher : functionMatcher; | ||
@@ -79,2 +79,6 @@ const getUrlMatcher = route => { | ||
if (typeof matcher === 'function') { | ||
return () => true; | ||
} | ||
if (matcher instanceof RegExp) { | ||
@@ -118,3 +122,4 @@ return url => matcher.test(url); | ||
route.params && getParamsMatcher(route), | ||
getFunctionMatcher(route) || getUrlMatcher(route) | ||
getFunctionMatcher(route), | ||
getUrlMatcher(route) | ||
].filter(matcher => !!matcher); | ||
@@ -121,0 +126,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1314345
8856