From d5b3eace4aa7fea2ee3fad32e2bb7e6c0d3d4236 Mon Sep 17 00:00:00 2001 From: Alex Tan Date: Sat, 10 Jul 2021 00:56:08 -0500 Subject: [PATCH] Don't check if path matches if it's not necessary --- customHeaders.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/customHeaders.go b/customHeaders.go index d10b540..f7c78e8 100644 --- a/customHeaders.go +++ b/customHeaders.go @@ -115,9 +115,11 @@ func customHeadersMiddleware(next http.Handler) http.Handler { matches = true } } else { - fileMatch := configEntry.FileExtension == "*" || reqFileExtension == "."+configEntry.FileExtension - pathMatch := configEntry.Path == "*" || strings.HasPrefix(r.URL.Path, configEntry.Path) - matches = fileMatch && pathMatch + matches = + // Check if the file extension matches. + (configEntry.FileExtension == "*" || reqFileExtension == "."+configEntry.FileExtension) && + // Check if the path matches. + (configEntry.Path == "*" || strings.HasPrefix(r.URL.Path, configEntry.Path)) } if matches {