Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
StefH authored Jul 17, 2024
1 parent fd00025 commit fd304fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,10 @@ public static MatchResult CalculateMatchScore(IBodyData? requestMessage, IMatche
}
}

// Check if the matcher is a IStringMatcher
if (matcher is IStringMatcher stringMatcher)
// In case the matcher is a IStringMatcher and If body is a Json or a String, use the BodyAsString to match on.
if (matcher is IStringMatcher stringMatcher && requestMessage.DetectedBodyType is BodyType.Json or BodyType.String or BodyType.FormUrlEncoded)
{
// If the body is a Json or a String, use the BodyAsString to match on.
if (requestMessage.DetectedBodyType is BodyType.Json or BodyType.String or BodyType.FormUrlEncoded)
{
return stringMatcher.IsMatch(requestMessage.BodyAsString);
}
return stringMatcher.IsMatch(requestMessage.BodyAsString);
}

return default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ public double GetMatchingScore(IRequestMessage requestMessage, IRequestMatchResu

private static MatchResult CalculateMatchResult(IRequestMessage requestMessage, IMatcher matcher)
{
// Check if the matcher is a IStringMatcher
// If the body is a Json or a String, use the BodyAsString to match on.
// In case the matcher is a IStringMatcher and the body is a Json or a String, use the BodyAsString to match on.
if (matcher is IStringMatcher stringMatcher && requestMessage.BodyData?.DetectedBodyType is BodyType.Json or BodyType.String or BodyType.FormUrlEncoded)
{
return stringMatcher.IsMatch(requestMessage.BodyData.BodyAsString);
Expand Down

0 comments on commit fd304fe

Please sign in to comment.