diff options
author | Bjørn Erik Pedersen <[email protected]> | 2017-06-20 17:20:08 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2017-06-20 17:21:31 +0200 |
commit | c43b512b4700f76ac77f12d632bb030c3a241393 (patch) | |
tree | 6df60d19c0abd5bd6c971d2cbd941f78223dbb82 /output/outputFormat_test.go | |
parent | 19f2e729135af700c5d4aa06e7b3540e6d4847fd (diff) | |
download | hugo-c43b512b4700f76ac77f12d632bb030c3a241393.tar.gz hugo-c43b512b4700f76ac77f12d632bb030c3a241393.zip |
output: Identify extension-less text types as text
See #3614
Diffstat (limited to 'output/outputFormat_test.go')
-rw-r--r-- | output/outputFormat_test.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/output/outputFormat_test.go b/output/outputFormat_test.go index 0540eac08..18b84a0fa 100644 --- a/output/outputFormat_test.go +++ b/output/outputFormat_test.go @@ -91,6 +91,47 @@ func TestGetFormatByExt(t *testing.T) { require.False(t, found) } +func TestGetFormatByFilename(t *testing.T) { + noExtNoDelimMediaType := media.TextType + noExtNoDelimMediaType.Suffix = "" + noExtNoDelimMediaType.Delimiter = "" + + noExtMediaType := media.TextType + noExtMediaType.Suffix = "" + + var ( + noExtDelimFormat = Format{ + Name: "NEM", + MediaType: noExtNoDelimMediaType, + BaseName: "_redirects", + } + noExt = Format{ + Name: "NEX", + MediaType: noExtMediaType, + BaseName: "next", + } + ) + + formats := Formats{AMPFormat, HTMLFormat, noExtDelimFormat, noExt, CalendarFormat} + f, found := formats.FromFilename("my.amp.html") + require.True(t, found) + require.Equal(t, AMPFormat, f) + f, found = formats.FromFilename("my.ics") + require.True(t, found) + f, found = formats.FromFilename("my.html") + require.True(t, found) + require.Equal(t, HTMLFormat, f) + f, found = formats.FromFilename("my.nem") + require.True(t, found) + require.Equal(t, noExtDelimFormat, f) + f, found = formats.FromFilename("my.nex") + require.True(t, found) + require.Equal(t, noExt, f) + f, found = formats.FromFilename("my.css") + require.False(t, found) + +} + func TestDecodeFormats(t *testing.T) { mediaTypes := media.Types{media.JSONType, media.XMLType} |