Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/Mockolate/Web/ItExtensions.HttpContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public IHttpContentHeaderParameter WithHeaders(params IEnumerable<(string Name,

/// <inheritdoc cref="IParameter.Matches(object?)" />
bool IParameter.Matches(object? value)
=> value is HttpContent content ? Matches(content) : value is null && Matches(null);
=> value is HttpContent content && Matches(content);

/// <inheritdoc cref="IParameter.InvokeCallbacks(object?)" />
void IParameter.InvokeCallbacks(object? value)
Expand Down
3 changes: 1 addition & 2 deletions Source/Mockolate/Web/ItExtensions.HttpRequestMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ protected virtual bool Matches(HttpRequestMessage value)
/// <inheritdoc cref="object.ToString()" />
public override string ToString()
{
// Stryker disable once Collection : the Where(!string.IsNullOrEmpty) filter at the return strips any default null entry, so seeding the list with [default] produces the same output as the empty seed.
List<string?> parts = [];
List<string?> parts = new();
if (_uriParameter is not null)
{
parts.Add(_uriParameter.ToString());
Expand Down
14 changes: 4 additions & 10 deletions Source/Mockolate/Web/ItExtensions.Uri.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Mockolate.Internals;
using Mockolate.Parameters;
#if NETSTANDARD2_0
using Mockolate.Internals.Polyfills;
#endif

namespace Mockolate.Web;
Expand Down Expand Up @@ -134,7 +133,7 @@ private sealed class UriParameter(string? pattern) : IUriParameter, IParameterMa

/// <inheritdoc cref="IParameter.Matches(object?)" />
bool IParameter.Matches(object? value)
=> value is Uri uri ? Matches(uri) : value is null && Matches(null);
=> value is Uri uri && Matches(uri);

/// <inheritdoc cref="IParameter.InvokeCallbacks(object?)" />
void IParameter.InvokeCallbacks(object? value)
Expand Down Expand Up @@ -215,15 +214,10 @@ private bool Matches(Uri? uri)
return false;
}

if (pattern is not null)
if (pattern is not null &&
!Wildcard.Pattern(pattern, true, false).Matches(uri.ToString()))
{
string requestUri1 = uri.ToString();
Wildcard wildcard = Wildcard.Pattern(pattern, true, false);
if (!wildcard.Matches(requestUri1) &&
(!requestUri1.EndsWith('/') || !wildcard.Matches(requestUri1.TrimEnd('/'))))
{
return false;
}
return false;
}

if (_scheme is not null &&
Expand Down
Loading