mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-02-23 18:54:51 +01:00
Fixes an issue with matching JSON bodies as bytes (#1339)
* Fixes an issue with matching JSON bodies as bytes * Adding tests for exact object matching * Simplify the check for byte data
This commit is contained in:
@@ -34,14 +34,10 @@ internal static class BodyDataMatchScoreCalculator
|
||||
}
|
||||
}
|
||||
|
||||
if (matcher is ExactObjectMatcher exactObjectMatcher)
|
||||
if (matcher is ExactObjectMatcher { Value: byte[] } exactObjectMatcher)
|
||||
{
|
||||
// If the body is a byte array, try to match.
|
||||
var detectedBodyType = requestMessage.DetectedBodyType;
|
||||
if (detectedBodyType is BodyType.Bytes or BodyType.String or BodyType.FormUrlEncoded)
|
||||
{
|
||||
return exactObjectMatcher.IsMatch(requestMessage.BodyAsBytes);
|
||||
}
|
||||
return exactObjectMatcher.IsMatch(requestMessage.BodyAsBytes);
|
||||
}
|
||||
|
||||
// Check if the matcher is a IObjectMatcher
|
||||
@@ -74,4 +70,4 @@ internal static class BodyDataMatchScoreCalculator
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user