mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
media: Add some more relevant MIME types
This commit is contained in:
parent
4923273688
commit
f2fbf0b2ea
2 changed files with 30 additions and 23 deletions
|
@ -47,11 +47,14 @@ func (m Type) String() string {
|
|||
}
|
||||
|
||||
var (
|
||||
CalendarType = Type{"text", "calendar", "ics"}
|
||||
CSSType = Type{"text", "css", "css"}
|
||||
HTMLType = Type{"text", "html", "html"}
|
||||
JSONType = Type{"application", "json", "json"}
|
||||
RSSType = Type{"application", "rss", "xml"}
|
||||
CalendarType = Type{"text", "calendar", "ics"}
|
||||
CSSType = Type{"text", "css", "css"}
|
||||
HTMLType = Type{"text", "html", "html"}
|
||||
JavascriptType = Type{"application", "javascript", "js"}
|
||||
JSONType = Type{"application", "json", "json"}
|
||||
RSSType = Type{"application", "rss", "xml"}
|
||||
XMLType = Type{"application", "xml", "xml"}
|
||||
TextType = Type{"text", "plain", "txt"}
|
||||
)
|
||||
|
||||
// TODO(bep) output mime.AddExtensionType
|
||||
|
|
|
@ -20,25 +20,29 @@ import (
|
|||
)
|
||||
|
||||
func TestDefaultTypes(t *testing.T) {
|
||||
require.Equal(t, "text", CalendarType.MainType)
|
||||
require.Equal(t, "calendar", CalendarType.SubType)
|
||||
require.Equal(t, "ics", CalendarType.Suffix)
|
||||
for _, test := range []struct {
|
||||
tp Type
|
||||
expectedMainType string
|
||||
expectedSubType string
|
||||
expectedSuffix string
|
||||
expectedType string
|
||||
expectedString string
|
||||
}{
|
||||
{CalendarType, "text", "calendar", "ics", "text/calendar", "text/calendar+ics"},
|
||||
{CSSType, "text", "css", "css", "text/css", "text/css+css"},
|
||||
{HTMLType, "text", "html", "html", "text/html", "text/html+html"},
|
||||
{JavascriptType, "application", "javascript", "js", "application/javascript", "application/javascript+js"},
|
||||
{JSONType, "application", "json", "json", "application/json", "application/json+json"},
|
||||
{RSSType, "application", "rss", "xml", "application/rss", "application/rss+xml"},
|
||||
{TextType, "text", "plain", "txt", "text/plain", "text/plain+txt"},
|
||||
} {
|
||||
require.Equal(t, test.expectedMainType, test.tp.MainType)
|
||||
require.Equal(t, test.expectedSubType, test.tp.SubType)
|
||||
require.Equal(t, test.expectedSuffix, test.tp.Suffix)
|
||||
|
||||
require.Equal(t, "text/calendar+ics", CalendarType.String())
|
||||
require.Equal(t, "text/calendar", CalendarType.Type())
|
||||
require.Equal(t, test.expectedType, test.tp.Type())
|
||||
require.Equal(t, test.expectedString, test.tp.String())
|
||||
|
||||
require.Equal(t, "text", HTMLType.MainType)
|
||||
require.Equal(t, "html", HTMLType.SubType)
|
||||
require.Equal(t, "html", HTMLType.Suffix)
|
||||
|
||||
require.Equal(t, "text/html", HTMLType.Type())
|
||||
require.Equal(t, "text/html+html", HTMLType.String())
|
||||
|
||||
require.Equal(t, "application", RSSType.MainType)
|
||||
require.Equal(t, "rss", RSSType.SubType)
|
||||
require.Equal(t, "xml", RSSType.Suffix)
|
||||
|
||||
require.Equal(t, "application/rss", RSSType.Type())
|
||||
require.Equal(t, "application/rss+xml", RSSType.String())
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue