Skip to content

Commit

Permalink
Fix sonar warnings in Obervability for AB#16872.
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianMaki committed Jan 7, 2025
1 parent 1855630 commit 719f1ba
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions Apps/Common/src/AspNetConfiguration/Modules/Observability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,23 @@ private static LogEventLevel ExcludePaths(HttpContext ctx, Exception? ex, string

private static bool IsWildcardMatch(PathString requestPath, string path)
{
return requestPath.HasValue &&
(path.StartsWith('*')
? requestPath.Value!.EndsWith(path.Replace("*", string.Empty, StringComparison.InvariantCultureIgnoreCase), StringComparison.InvariantCultureIgnoreCase)
: requestPath.Equals(path, StringComparison.InvariantCultureIgnoreCase));
if (!requestPath.HasValue)
{
return false;
}

string requestPathValue = requestPath.Value!;

return path switch
{
_ when path.EndsWith('*') => requestPathValue.StartsWith(
path.TrimEnd('*'),
StringComparison.InvariantCultureIgnoreCase),
_ when path.StartsWith('*') => requestPathValue.EndsWith(
path.TrimStart('*'),
StringComparison.InvariantCultureIgnoreCase),
_ => requestPath.Equals(path, StringComparison.InvariantCultureIgnoreCase),
};
}
}
}

0 comments on commit 719f1ba

Please sign in to comment.