Skip to content

Commit

Permalink
Allow matching of params for POST requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Reagan committed Mar 9, 2021
1 parent c4d95d7 commit 6793904
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,20 @@ function isUrlMatching(url, required) {

function isBodyOrParametersMatching(method, body, parameters, required) {
var allowedParamsMethods = ["delete", "get", "head", "options"];
if (allowedParamsMethods.indexOf(method.toLowerCase()) >= 0) {
var params = required ? required.params : undefined;
return isObjectMatching(parameters, params);
} else {
return isBodyMatching(body, required);
var params;

if (required) {
({ params } = required);
delete required["params"];
}

var matching = isObjectMatching(parameters, params);

if (!allowedParamsMethods.indexOf(method.toLowerCase()) >= 0) {
matching = matching && isBodyMatching(body, required);
}

return matching;
}

function isObjectMatching(actual, expected) {
Expand Down

0 comments on commit 6793904

Please sign in to comment.