express-mock-api-middleware
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -100,4 +100,5 @@ "use strict"; | ||
path = splited[1]; // eslint-disable-line | ||
} | ||
} // debug(`parsed: ${method} ${path}`); | ||
(0, _assert.default)(VALID_METHODS.includes(method), "Invalid method ".concat(method, " for path ").concat(path, ", please check your mock files.")); | ||
@@ -153,3 +154,8 @@ return { | ||
var keys = []; | ||
var re = (0, _pathToRegexp.default)(path, keys); | ||
var pathOptions = { | ||
whitelist: ['%'] // treat %3A as regular chars | ||
}; | ||
var re = (0, _pathToRegexp.default)(path, keys, pathOptions); // debug(re); | ||
memo.push({ | ||
@@ -175,4 +181,5 @@ method: method, | ||
function matchMock(req) { | ||
var exceptPath = req.path; | ||
var exceptMethod = req.method.toLowerCase(); | ||
var targetPath = req.path; | ||
var targetMethod = req.method.toLowerCase(); // debug(`${targetMethod} ${targetPath}`); | ||
var _iteratorNormalCompletion = true; | ||
@@ -189,4 +196,4 @@ var _didIteratorError = false; | ||
if (method === exceptMethod) { | ||
var match = re.exec(req.path); | ||
if (method === targetMethod) { | ||
var match = re.exec(targetPath); | ||
@@ -247,3 +254,3 @@ if (match) { | ||
re = _ref.re; | ||
return method === exceptMethod && re.test(exceptPath); | ||
return method === targetMethod && re.test(targetPath); | ||
})[0]; | ||
@@ -250,0 +257,0 @@ } |
{ | ||
"name": "express-mock-api-middleware", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Express middleware for mocking restful APIs", | ||
@@ -8,3 +8,3 @@ "main": "lib/index.js", | ||
"build": "babel src -d lib", | ||
"prepack": "npm build" | ||
"prepack": "npm run build" | ||
}, | ||
@@ -11,0 +11,0 @@ "repository": { |
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
11660
229