Skip to content

fix: do not invent trailing slash for Uri match#386

Merged
vbreuss merged 2 commits into
mainfrom
topic/fix-trailing-slash-for-uri-match
Jan 24, 2026
Merged

fix: do not invent trailing slash for Uri match#386
vbreuss merged 2 commits into
mainfrom
topic/fix-trailing-slash-for-uri-match

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented Jan 24, 2026

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:

  • Modified ItExtensions.Uri.cs and HttpClientExtensions.cs to fix trailing slash handling in URI matching
  • Added comprehensive test coverage for trailing slash scenarios
  • Added tests verifying callback invocation with .Do() method

@vbreuss vbreuss self-assigned this Jan 24, 2026
@vbreuss vbreuss added the bug Something isn't working label Jan 24, 2026
Copilot AI review requested due to automatic review settings January 24, 2026 06:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.cs and HttpClientExtensions.cs to 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

@vbreuss vbreuss enabled auto-merge (squash) January 24, 2026 06:53
@vbreuss vbreuss force-pushed the topic/fix-trailing-slash-for-uri-match branch from 073e951 to 523e23b Compare January 24, 2026 06:57
Copilot AI review requested due to automatic review settings January 24, 2026 06:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 24, 2026

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763 2.83GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.102
[Host] : .NET 10.0.2 (10.0.2, 10.0.225.61305), X64 RyuJIT x86-64-v3

Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15
LaunchCount=1 WarmupCount=10

Method Mean Error StdDev Gen0 Gen1 Allocated
Simple_Mockolate 1.458 μs 0.0068 μs 0.0060 μs 0.2270 - 3.73 KB
Simple_Moq 174.580 μs 1.0018 μs 0.8881 μs 0.4883 - 14.55 KB
Simple_NSubstitute 5.469 μs 0.0168 μs 0.0157 μs 0.5493 0.0076 9.09 KB
Simple_FakeItEasy 6.389 μs 0.0200 μs 0.0177 μs 0.5035 - 8.27 KB

@vbreuss vbreuss disabled auto-merge January 24, 2026 06:58
@vbreuss vbreuss merged commit 47753ac into main Jan 24, 2026
8 checks passed
@vbreuss vbreuss deleted the topic/fix-trailing-slash-for-uri-match branch January 24, 2026 06:58
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

This is addressed in release v1.0.1.

@github-actions github-actions Bot added the state: released The issue is released label Jan 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants