fix: do not invent trailing slash for Uri match#386
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in URI matching logic that was incorrectly adding trailing slashes when they shouldn't be added. The fix changes the matching behavior to only try removing trailing slashes when they exist in the actual URI, rather than inventing them.
Changes:
- Modified
ItExtensions.Uri.csandHttpClientExtensions.csto fix trailing slash handling in URI matching - Added comprehensive test coverage for trailing slash scenarios
- Added tests verifying callback invocation with
.Do()method - Reordered test methods and reformatted byte array test data for consistency
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Source/Mockolate/Web/ItExtensions.Uri.cs | Fixed URI matching to only remove trailing slashes when present, not add them |
| Source/Mockolate/Web/HttpClientExtensions.cs | Applied same trailing slash fix to HttpClient extension matching logic |
| Tests/Mockolate.Tests/Web/ItExtensionsTests.UriTests.cs | Added tests for trailing slash behavior and callback invocation |
| Tests/Mockolate.Tests/Web/HttpClientExtensionsTests.cs | Added tests for trailing slash scenarios and callback monitoring |
| Tests/Mockolate.Tests/Web/ItExtensionsTests.IsStringContentTests.cs | Added test verifying callback count with .Do() |
| Tests/Mockolate.Tests/Web/ItExtensionsTests.IsBinaryContentTests.cs | Added callback count verification and reformatted byte array test data |
| Tests/Mockolate.Tests/MockMethods/VerifyInvokedTests.cs | Reordered test methods and added test for method name mismatch with parameters |
| Source/Mockolate/MockRegistration.Setup.cs | Added ExcludeFromCodeCoverage attribute to internal comparer class |
073e951 to
523e23b
Compare
🚀 Benchmark ResultsDetails
|
|
|
This is addressed in release v1.0.1. |



This PR fixes a bug in URI matching logic that was incorrectly adding trailing slashes when they shouldn't be added. The fix changes the matching behavior to only try removing trailing slashes when they exist in the actual URI, rather than inventing them.
Key Changes:
ItExtensions.Uri.csandHttpClientExtensions.csto fix trailing slash handling in URI matching.Do()method