Don't check if path matches if it's not necessary

This commit is contained in:
Alex Tan 2021-07-10 00:56:08 -05:00
parent 06466faa87
commit d5b3eace4a

View file

@ -115,9 +115,11 @@ func customHeadersMiddleware(next http.Handler) http.Handler {
matches = true matches = true
} }
} else { } else {
fileMatch := configEntry.FileExtension == "*" || reqFileExtension == "."+configEntry.FileExtension matches =
pathMatch := configEntry.Path == "*" || strings.HasPrefix(r.URL.Path, configEntry.Path) // Check if the file extension matches.
matches = fileMatch && pathMatch (configEntry.FileExtension == "*" || reqFileExtension == "."+configEntry.FileExtension) &&
// Check if the path matches.
(configEntry.Path == "*" || strings.HasPrefix(r.URL.Path, configEntry.Path))
} }
if matches { if matches {