Custom Error Pages: Accept first of many MIME types. (#13005)

This commit is contained in:
Jeremy 2025-03-22 03:32:32 -07:00 committed by GitHub
parent 9b74afd990
commit 922d2520f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions

View File

@ -126,6 +126,12 @@ func errorHandler(path, defaultFormat string) func(http.ResponseWriter, *http.Re
log.Printf("format not specified. Using %v", format)
}
// if multiple formats are provided, use the first one
index := strings.Index(format, ",")
if index != -1 {
format = format[:index]
}
cext, err := mime.ExtensionsByType(format)
if err != nil {
log.Printf("unexpected error reading media type extension: %v. Using %v", err, ext)