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
}
} 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 {