Socket
Socket
Sign inDemoInstall

fetch-mock

Package Overview
Dependencies
Maintainers
3
Versions
226
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-mock - npm Package Compare versions

Comparing version 8.0.3 to 8.1.0

38

cjs/lib/generate-matcher.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc