diff options
author | Bjørn Erik Pedersen <[email protected]> | 2021-03-11 09:18:01 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2021-03-14 15:21:54 +0100 |
commit | ba1d0051b44fdd242b20899e195e37ab26501516 (patch) | |
tree | 646f815cf5eb027bae13e329696acf14d640d3f9 /resources/resource_spec.go | |
parent | 1b1dcf586e220c3a8ad5ecfa8e4c3dac97f0ab44 (diff) | |
download | hugo-ba1d0051b44fdd242b20899e195e37ab26501516.tar.gz hugo-ba1d0051b44fdd242b20899e195e37ab26501516.zip |
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
Diffstat (limited to 'resources/resource_spec.go')
-rw-r--r-- | resources/resource_spec.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/resources/resource_spec.go b/resources/resource_spec.go index dc13d16d9..156def363 100644 --- a/resources/resource_spec.go +++ b/resources/resource_spec.go @@ -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") } |