summaryrefslogtreecommitdiffhomepage
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2018-08-28 14:18:12 +0200
committerBjørn Erik Pedersen <[email protected]>2018-08-28 17:00:53 +0200
commitebb56e8bdbfaf4f955326017e40b2805850871e9 (patch)
tree64935a5bfaeb5b2cc8e5c600ad2403d32d3de65c /hugolib
parent6b9934a26615ea614b1774770532cae9762a58d3 (diff)
downloadhugo-ebb56e8bdbfaf4f955326017e40b2805850871e9.tar.gz
hugo-ebb56e8bdbfaf4f955326017e40b2805850871e9.zip
Improve minifier MIME type resolution
This commit also removes the deprecated `Suffix` from MediaType. Now use `Suffixes` and put the MIME type suffix in the type, e.g. `application/svg+xml`. Fixes #5093
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/config_test.go16
-rw-r--r--hugolib/page_bundler_test.go2
-rw-r--r--hugolib/site_output_test.go10
3 files changed, 14 insertions, 14 deletions
diff --git a/hugolib/config_test.go b/hugolib/config_test.go
index 16d07d1af..1f9e7377c 100644
--- a/hugolib/config_test.go
+++ b/hugolib/config_test.go
@@ -97,7 +97,7 @@ top = "top"
[mediaTypes]
[mediaTypes."text/m1"]
-suffix = "m1main"
+suffixes = ["m1main"]
[outputFormats.o1]
mediaType = "text/m1"
@@ -135,9 +135,9 @@ p3 = "p3 theme"
[mediaTypes]
[mediaTypes."text/m1"]
-suffix = "m1theme"
+suffixes = ["m1theme"]
[mediaTypes."text/m2"]
-suffix = "m2theme"
+suffixes = ["m2theme"]
[outputFormats.o1]
mediaType = "text/m1"
@@ -207,10 +207,14 @@ map[string]interface {}{
b.AssertObject(`
map[string]interface {}{
"text/m1": map[string]interface {}{
- "suffix": "m1main",
+ "suffixes": []interface {}{
+ "m1main",
+ },
},
"text/m2": map[string]interface {}{
- "suffix": "m2theme",
+ "suffixes": []interface {}{
+ "m2theme",
+ },
},
}`, got["mediatypes"])
@@ -221,7 +225,6 @@ map[string]interface {}{
"mediatype": Type{
MainType: "text",
SubType: "m1",
- OldSuffix: "m1main",
Delimiter: ".",
Suffixes: []string{
"m1main",
@@ -233,7 +236,6 @@ map[string]interface {}{
"mediatype": Type{
MainType: "text",
SubType: "m2",
- OldSuffix: "m2theme",
Delimiter: ".",
Suffixes: []string{
"m2theme",
diff --git a/hugolib/page_bundler_test.go b/hugolib/page_bundler_test.go
index 236672b65..cfbec04b7 100644
--- a/hugolib/page_bundler_test.go
+++ b/hugolib/page_bundler_test.go
@@ -435,7 +435,7 @@ func newTestBundleSources(t *testing.T) (*hugofs.Fs, *viper.Viper) {
cfg.Set("baseURL", "https://example.com")
cfg.Set("mediaTypes", map[string]interface{}{
"text/bepsays": map[string]interface{}{
- "suffix": "bep",
+ "suffixes": []string{"bep"},
},
})
diff --git a/hugolib/site_output_test.go b/hugolib/site_output_test.go
index 0677dfbfb..e9a7e113e 100644
--- a/hugolib/site_output_test.go
+++ b/hugolib/site_output_test.go
@@ -276,14 +276,12 @@ disableKinds = ["page", "section", "taxonomy", "taxonomyTerm", "sitemap", "robot
[mediaTypes]
[mediaTypes."text/nodot"]
-suffix = ""
delimiter = ""
[mediaTypes."text/defaultdelim"]
-suffix = "defd"
+suffixes = ["defd"]
[mediaTypes."text/nosuffix"]
-suffix = ""
[mediaTypes."text/customdelim"]
-suffix = "del"
+suffixes = ["del"]
delimiter = "_"
[outputs]
@@ -321,7 +319,7 @@ baseName = "customdelimbase"
th.assertFileContent("public/_redirects", "a dotless")
th.assertFileContent("public/defaultdelimbase.defd", "default delimim")
// This looks weird, but the user has chosen this definition.
- th.assertFileContent("public/nosuffixbase.", "no suffix")
+ th.assertFileContent("public/nosuffixbase", "no suffix")
th.assertFileContent("public/customdelimbase_del", "custom delim")
s := h.Sites[0]
@@ -332,7 +330,7 @@ baseName = "customdelimbase"
require.Equal(t, "/blog/_redirects", outputs.Get("DOTLESS").RelPermalink())
require.Equal(t, "/blog/defaultdelimbase.defd", outputs.Get("DEF").RelPermalink())
- require.Equal(t, "/blog/nosuffixbase.", outputs.Get("NOS").RelPermalink())
+ require.Equal(t, "/blog/nosuffixbase", outputs.Get("NOS").RelPermalink())
require.Equal(t, "/blog/customdelimbase_del", outputs.Get("CUS").RelPermalink())
}