mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
media: Add missing BMP and GIF to the default MediaTypes list
This commit is contained in:
parent
cdc73526a8
commit
ce04011096
4 changed files with 14 additions and 1 deletions
|
@ -274,6 +274,8 @@ var DefaultTypes = Types{
|
|||
YAMLType,
|
||||
TOMLType,
|
||||
PNGType,
|
||||
GIFType,
|
||||
BMPType,
|
||||
JPEGType,
|
||||
WEBPType,
|
||||
AVIType,
|
||||
|
@ -289,6 +291,15 @@ var DefaultTypes = Types{
|
|||
|
||||
func init() {
|
||||
sort.Sort(DefaultTypes)
|
||||
|
||||
// Sanity check.
|
||||
seen := make(map[Type]bool)
|
||||
for _, t := range DefaultTypes {
|
||||
if seen[t] {
|
||||
panic(fmt.Sprintf("MediaType %s duplicated in list", t))
|
||||
}
|
||||
seen[t] = true
|
||||
}
|
||||
}
|
||||
|
||||
// Types is a slice of media types.
|
||||
|
|
|
@ -15,6 +15,7 @@ package media
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
|
@ -63,7 +64,7 @@ func TestDefaultTypes(t *testing.T) {
|
|||
|
||||
}
|
||||
|
||||
c.Assert(len(DefaultTypes), qt.Equals, 31)
|
||||
c.Assert(len(DefaultTypes), qt.Equals, 33)
|
||||
}
|
||||
|
||||
func TestGetByType(t *testing.T) {
|
||||
|
@ -193,6 +194,7 @@ func TestFromContent(t *testing.T) {
|
|||
content, err := ioutil.ReadFile(filename)
|
||||
c.Assert(err, qt.IsNil)
|
||||
ext := strings.TrimPrefix(paths.Ext(filename), ".")
|
||||
fmt.Println("=>", ext)
|
||||
expected, _, found := mtypes.GetFirstBySuffix(ext)
|
||||
c.Assert(found, qt.IsTrue)
|
||||
got := FromContent(mtypes, ext, content)
|
||||
|
|
BIN
media/testdata/resource.bmp
vendored
Normal file
BIN
media/testdata/resource.bmp
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
BIN
media/testdata/resource.gif
vendored
Normal file
BIN
media/testdata/resource.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 161 B |
Loading…
Reference in a new issue