Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

parrot-core

Package Overview
Dependencies
Maintainers
0
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parrot-core - npm Package Compare versions

Comparing version 5.0.1 to 5.1.0

17

lib/utils/getParams.js
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -8,3 +7,3 @@ value: true

exports.default = getParams;
var _pathToRegexp = _interopRequireDefault(require("path-to-regexp"));
var _pathToRegexp = require("path-to-regexp");
/*

@@ -25,10 +24,8 @@ * Copyright (c) 2018 American Express Travel Related Services Company, Inc.

function getParams(path, route) {
const keys = [];
const [, ...values] = (0, _pathToRegexp.default)(route, keys).exec(path);
return keys.reduce((acc, {
name
}, index) => ({
...acc,
[name]: values[index]
}), {});
const matchRoute = (0, _pathToRegexp.match)(route);
const result = matchRoute(path);
if (!result) {
return {};
}
return result.params;
}

@@ -10,3 +10,3 @@ "use strict";

var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
var _pathToRegexp = _interopRequireDefault(require("path-to-regexp"));
var _pathToRegexp = require("path-to-regexp");
var _logger = _interopRequireDefault(require("./logger"));

@@ -27,6 +27,8 @@ /*

function match(normalizedRequest) {
function matchRequest(normalizedRequest) {
return request => Object.keys(request).every(property => {
if (property === 'path') {
return (0, _pathToRegexp.default)(request.path).exec(normalizedRequest.path);
const matchRoute = (0, _pathToRegexp.match)(request.path);
const result = matchRoute(normalizedRequest.path);
return result !== false;
}

@@ -50,3 +52,3 @@ if (property === 'headers') {

if (typeof mock === 'function') {
const response = mock(normalizedRequest, match(normalizedRequest), ...[].concat(platformRequest));
const response = mock(normalizedRequest, matchRequest(normalizedRequest), ...[].concat(platformRequest));
if (response) {

@@ -59,7 +61,7 @@ matchedMock = {

}
} else if (typeof mock.request === 'function' && mock.request(normalizedRequest, match(normalizedRequest))) {
} else if (typeof mock.request === 'function' && mock.request(normalizedRequest, matchRequest(normalizedRequest))) {
_logger.default.info('Matched request function.', normalizedRequest.path);
matchedMock = mock;
break;
} else if (typeof mock.request === 'object' && match(normalizedRequest)(mock.request)) {
} else if (typeof mock.request === 'object' && matchRequest(normalizedRequest)(mock.request)) {
_logger.default.info(`Matched request object: ${_util.default.inspect(mock.request, {

@@ -66,0 +68,0 @@ colors: true,

{
"name": "parrot-core",
"version": "5.0.1",
"version": "5.1.0",
"contributors": [

@@ -30,3 +30,3 @@ "Jack Cross <jack.cross1@aexp.com>",

"lodash": "^4.17.21",
"path-to-regexp": "^3.3.0",
"path-to-regexp": "^8.2.0",
"util-inspect": "^0.1.8"

@@ -41,3 +41,3 @@ },

},
"gitHead": "23a15b80762809b35253020b8d8f24bfc789147d"
"gitHead": "392c66c11bb8ae8a4fe7131f73f2b711851cfe41"
}
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