mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-12 20:13:59 +02:00
media: Make Type comparable
So we can use it and output.Format as map key etc. This commit also fixes the media.Type implementation so it does not need to mutate itself to handle different suffixes for the same MIME type, e.g. jpg vs. jpeg. This means that there are no Suffix or FullSuffix on media.Type anymore. Fixes #8317 Fixes #8324
This commit is contained in:
@@ -268,10 +268,10 @@ func (r *Spec) newResource(sourceFs afero.Fs, fd ResourceSourceDescriptor) (reso
|
||||
}
|
||||
|
||||
ext := strings.ToLower(filepath.Ext(fd.RelTargetFilename))
|
||||
mimeType, found := r.MediaTypes.GetFirstBySuffix(strings.TrimPrefix(ext, "."))
|
||||
mimeType, suffixInfo, found := r.MediaTypes.GetFirstBySuffix(strings.TrimPrefix(ext, "."))
|
||||
// TODO(bep) we need to handle these ambiguous types better, but in this context
|
||||
// we most likely want the application/xml type.
|
||||
if mimeType.Suffix() == "xml" && mimeType.SubType == "rss" {
|
||||
if suffixInfo.Suffix == "xml" && mimeType.SubType == "rss" {
|
||||
mimeType, found = r.MediaTypes.GetByType("application/xml")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user