mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-28 21:21:40 -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,
|
YAMLType,
|
||||||
TOMLType,
|
TOMLType,
|
||||||
PNGType,
|
PNGType,
|
||||||
|
GIFType,
|
||||||
|
BMPType,
|
||||||
JPEGType,
|
JPEGType,
|
||||||
WEBPType,
|
WEBPType,
|
||||||
AVIType,
|
AVIType,
|
||||||
|
@ -289,6 +291,15 @@ var DefaultTypes = Types{
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
sort.Sort(DefaultTypes)
|
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.
|
// Types is a slice of media types.
|
||||||
|
|
|
@ -15,6 +15,7 @@ package media
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"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) {
|
func TestGetByType(t *testing.T) {
|
||||||
|
@ -193,6 +194,7 @@ func TestFromContent(t *testing.T) {
|
||||||
content, err := ioutil.ReadFile(filename)
|
content, err := ioutil.ReadFile(filename)
|
||||||
c.Assert(err, qt.IsNil)
|
c.Assert(err, qt.IsNil)
|
||||||
ext := strings.TrimPrefix(paths.Ext(filename), ".")
|
ext := strings.TrimPrefix(paths.Ext(filename), ".")
|
||||||
|
fmt.Println("=>", ext)
|
||||||
expected, _, found := mtypes.GetFirstBySuffix(ext)
|
expected, _, found := mtypes.GetFirstBySuffix(ext)
|
||||||
c.Assert(found, qt.IsTrue)
|
c.Assert(found, qt.IsTrue)
|
||||||
got := FromContent(mtypes, ext, content)
|
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