Skip to content

Commit 4fea465

Browse files
committed
Using string.IsNullOrEmpty / Adding extra comments
1 parent 8fd539d commit 4fea465

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,13 @@ static double GetElapsedMilliseconds(long start, long stop)
106106

107107
static string GetPath(HttpContext httpContext)
108108
{
109+
/*
110+
In some cases, like when running integration tests with WebApplicationFactory<T>
111+
the RawTarget returns an empty string instead of null, in that case we can't use
112+
?? as fallback.
113+
*/
109114
var requestPath = httpContext.Features.Get<IHttpRequestFeature>()?.RawTarget;
110-
if (string.IsNullOrWhiteSpace(requestPath))
115+
if (string.IsNullOrEmpty(requestPath))
111116
{
112117
requestPath = httpContext.Request.Path.ToString();
113118
}

0 commit comments

Comments
 (0)