Socket
Socket
Sign inDemoInstall

egg-mock

Package Overview
Dependencies
402
Maintainers
14
Versions
125
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.10.8 to 5.10.9

28

lib/mock_httpclient.js

@@ -66,2 +66,5 @@ const mm = require('mm');

const MOCK_CONFIGS = Symbol('MOCK_CONFIGS');
const MOCK_CONFIG_INDEX = Symbol('MOCK_CONFIG_INDEX');
return function mockHttpclient(mockUrl, mockMethod, mockResult) {

@@ -78,2 +81,9 @@ if (!mockResult) {

// use MockAgent on undici
let mockConfigs = app[MOCK_CONFIGS];
if (!mockConfigs) {
mockConfigs = [];
mm(app, MOCK_CONFIGS, mockConfigs);
}
let mockConfigIndex = -1;
let origin = mockUrl;

@@ -98,4 +108,12 @@ let pathname = mockUrl;

pathname = path => {
return mockUrl.test(`${requestOrigin}${path}`);
for (const config of mockConfigs) {
if (config.mockUrl.test(`${requestOrigin}${path}`)) {
mm(app, MOCK_CONFIG_INDEX, config.mockConfigIndex);
return true;
}
}
return false;
};
mockConfigIndex = mockConfigs.length;
mockConfigs.push({ mockUrl, mockResult, mockConfigIndex });
}

@@ -115,3 +133,9 @@ const mockPool = mockAgent.getAgent().get(origin);

const requestUrl = `${options.origin}${options.path}`;
const mockRequestResult = is.function(mockResult) ? mockResult(requestUrl, options) : mockResult;
let mockRequestResult;
if (mockConfigIndex >= 0) {
mockResult = mockConfigs[app[MOCK_CONFIG_INDEX]].mockResult;
mockRequestResult = is.function(mockResult) ? mockResult(requestUrl, options) : mockResult;
} else {
mockRequestResult = is.function(mockResult) ? mockResult(requestUrl, options) : mockResult;
}
const result = extend(true, {}, normalizeResult(mockRequestResult));

@@ -118,0 +142,0 @@ return {

2

package.json
{
"name": "egg-mock",
"version": "5.10.8",
"version": "5.10.9",
"eggPlugin": {

@@ -5,0 +5,0 @@ "name": "egg-mock"

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc