fetch-mock
Advanced tools
Comparing version 8.0.3 to 8.1.0
@@ -93,2 +93,20 @@ const glob = require('glob-to-regexp'); | ||
const getFullUrlMatcher = (route, matcher, query) => { | ||
// if none of the special syntaxes apply, it's just a simple string match | ||
// but we have to be careful to normalize the url we check and the name | ||
// of the route to allow for e.g. http://it.at.there being indistinguishable | ||
// from http://it.at.there/ once we start generating Request/Url objects | ||
const expectedUrl = normalizeUrl(matcher); | ||
if (route.identifier === matcher) { | ||
route.identifier = expectedUrl; | ||
} | ||
return url => { | ||
if (query && expectedUrl.indexOf('?')) { | ||
return url.indexOf(expectedUrl) === 0; | ||
} | ||
return normalizeUrl(url) === expectedUrl; | ||
}; | ||
}; | ||
const getUrlMatcher = route => { | ||
@@ -109,2 +127,6 @@ const { matcher, query } = route; | ||
if (matcher.href) { | ||
return getFullUrlMatcher(route, matcher.href, query); | ||
} | ||
for (const shorthand in stringMatchers) { | ||
@@ -117,17 +139,3 @@ if (matcher.indexOf(shorthand + ':') === 0) { | ||
// if none of the special syntaxes apply, it's just a simple string match | ||
// but we have to be careful to normalize the url we check and the name | ||
// of the route to allow for e.g. http://it.at.there being indistinguishable | ||
// from http://it.at.there/ once we start generating Request/Url objects | ||
const expectedUrl = normalizeUrl(matcher); | ||
if (route.identifier === matcher) { | ||
route.identifier = expectedUrl; | ||
} | ||
return url => { | ||
if (query && expectedUrl.indexOf('?')) { | ||
return url.indexOf(expectedUrl) === 0; | ||
} | ||
return normalizeUrl(url) === expectedUrl; | ||
}; | ||
return getFullUrlMatcher(route, matcher, query); | ||
}; | ||
@@ -134,0 +142,0 @@ |
@@ -151,2 +151,20 @@ 'use strict'; | ||
var getFullUrlMatcher = function getFullUrlMatcher(route, matcher, query) { | ||
// if none of the special syntaxes apply, it's just a simple string match | ||
// but we have to be careful to normalize the url we check and the name | ||
// of the route to allow for e.g. http://it.at.there being indistinguishable | ||
// from http://it.at.there/ once we start generating Request/Url objects | ||
var expectedUrl = normalizeUrl(matcher); | ||
if (route.identifier === matcher) { | ||
route.identifier = expectedUrl; | ||
} | ||
return function (url) { | ||
if (query && expectedUrl.indexOf('?')) { | ||
return url.indexOf(expectedUrl) === 0; | ||
} | ||
return normalizeUrl(url) === expectedUrl; | ||
}; | ||
}; | ||
var getUrlMatcher = function getUrlMatcher(route) { | ||
@@ -175,2 +193,6 @@ var matcher = route.matcher, | ||
if (matcher.href) { | ||
return getFullUrlMatcher(route, matcher.href, query); | ||
} | ||
for (var shorthand in stringMatchers) { | ||
@@ -183,17 +205,3 @@ if (matcher.indexOf(shorthand + ':') === 0) { | ||
// if none of the special syntaxes apply, it's just a simple string match | ||
// but we have to be careful to normalize the url we check and the name | ||
// of the route to allow for e.g. http://it.at.there being indistinguishable | ||
// from http://it.at.there/ once we start generating Request/Url objects | ||
var expectedUrl = normalizeUrl(matcher); | ||
if (route.identifier === matcher) { | ||
route.identifier = expectedUrl; | ||
} | ||
return function (url) { | ||
if (query && expectedUrl.indexOf('?')) { | ||
return url.indexOf(expectedUrl) === 0; | ||
} | ||
return normalizeUrl(url) === expectedUrl; | ||
}; | ||
return getFullUrlMatcher(route, matcher, query); | ||
}; | ||
@@ -200,0 +208,0 @@ |
{ | ||
"name": "fetch-mock", | ||
"type": "module", | ||
"version": "8.0.3", | ||
"version": "8.1.0", | ||
"description": "Mock http requests made using fetch (or isomorphic-fetch)", | ||
@@ -6,0 +6,0 @@ "main": "./cjs/server.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
2613555
74589