mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-22 21:42:50 +02:00
Fix Resource.ResourceType so it always returns MIME's main type
The one exception being for the Page, which does not have a MIME type, in which you will get the value `page`. Fixes #8052
This commit is contained in:
@@ -38,7 +38,7 @@ func TestGenericResource(t *testing.T) {
|
||||
|
||||
c.Assert(r.Permalink(), qt.Equals, "https://example.com/foo.css")
|
||||
c.Assert(r.RelPermalink(), qt.Equals, "/foo.css")
|
||||
c.Assert(r.ResourceType(), qt.Equals, "css")
|
||||
c.Assert(r.ResourceType(), qt.Equals, "text")
|
||||
}
|
||||
|
||||
func TestGenericResourceWithLinkFactory(t *testing.T) {
|
||||
@@ -52,7 +52,7 @@ func TestGenericResourceWithLinkFactory(t *testing.T) {
|
||||
c.Assert(r.Permalink(), qt.Equals, "https://example.com/foo/foo.css")
|
||||
c.Assert(r.RelPermalink(), qt.Equals, "/foo/foo.css")
|
||||
c.Assert(r.Key(), qt.Equals, "/foo/foo.css")
|
||||
c.Assert(r.ResourceType(), qt.Equals, "css")
|
||||
c.Assert(r.ResourceType(), qt.Equals, "text")
|
||||
}
|
||||
|
||||
func TestNewResourceFromFilename(t *testing.T) {
|
||||
@@ -76,7 +76,7 @@ func TestNewResourceFromFilename(t *testing.T) {
|
||||
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(r, qt.Not(qt.IsNil))
|
||||
c.Assert(r.ResourceType(), qt.Equals, "json")
|
||||
c.Assert(r.ResourceType(), qt.Equals, "application")
|
||||
}
|
||||
|
||||
func TestNewResourceFromFilenameSubPathInBaseURL(t *testing.T) {
|
||||
@@ -108,7 +108,7 @@ func TestResourcesByType(t *testing.T) {
|
||||
spec.newGenericResource(nil, nil, nil, "/a/foo3.css", "foo3.css", media.CSSType),
|
||||
}
|
||||
|
||||
c.Assert(len(resources.ByType("css")), qt.Equals, 3)
|
||||
c.Assert(len(resources.ByType("text")), qt.Equals, 3)
|
||||
c.Assert(len(resources.ByType("image")), qt.Equals, 1)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user