Skip to content

Commit e8250e1

Browse files
authored
Extend ExcludePathPatterns (#31)
* Extend ExcludePathPatterns * Fix
1 parent 1569941 commit e8250e1

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/Apitally/RequestLogger.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ class RequestLogger(IOptions<ApitallyOptions> options, ILogger<RequestLogger> lo
3131
"/ping$",
3232
"/ready$",
3333
"/live$",
34+
"/favicon(?:-[\\w-]+)?\\.(ico|png|svg)$",
35+
"/apple-touch-icon(?:-[\\w-]+)?\\.png$",
36+
"/robots\\.txt$",
37+
"/sitemap\\.xml$",
38+
"/manifest\\.json$",
39+
"/site\\.webmanifest$",
40+
"/service-worker\\.js$",
41+
"/sw\\.js$",
42+
"/\\.well-known/",
3443
];
3544
private static readonly string[] ExcludeUserAgentPatterns =
3645
[
@@ -140,9 +149,13 @@ public void LogRequest(
140149

141150
try
142151
{
152+
var path =
153+
!string.IsNullOrEmpty(request.Path) ? request.Path
154+
: !string.IsNullOrEmpty(request.Url) ? new Uri(request.Url).AbsolutePath
155+
: string.Empty;
143156
var userAgent = GetHeaderValue(request.Headers, "user-agent");
144157
if (
145-
ShouldExcludePath(request.Path)
158+
ShouldExcludePath(path)
146159
|| ShouldExcludeUserAgent(userAgent)
147160
|| requestLoggingOptions.ShouldExclude(request, response)
148161
)

0 commit comments

Comments
 (0)