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:
Bjørn Erik Pedersen 2021-03-11 09:18:01 +01:00
parent 1b1dcf586e
commit ba1d0051b4
19 changed files with 254 additions and 195 deletions

View file

@ -432,7 +432,7 @@ func (lf *localFile) ContentType() string {
}
ext := filepath.Ext(lf.NativePath)
if mimeType, found := lf.mediaTypes.GetFirstBySuffix(strings.TrimPrefix(ext, ".")); found {
if mimeType, _, found := lf.mediaTypes.GetFirstBySuffix(strings.TrimPrefix(ext, ".")); found {
return mimeType.Type()
}