summaryrefslogtreecommitdiffstats
path: root/output
diff options
context:
space:
mode:
Diffstat (limited to 'output')
-rw-r--r--output/docshelper.go2
-rw-r--r--output/layout.go6
-rw-r--r--output/layout_test.go5
-rw-r--r--output/outputFormat.go4
-rw-r--r--output/outputFormat_test.go4
5 files changed, 11 insertions, 10 deletions
diff --git a/output/docshelper.go b/output/docshelper.go
index 4c724b020..ad16d3257 100644
--- a/output/docshelper.go
+++ b/output/docshelper.go
@@ -72,7 +72,7 @@ func createLayoutExamples() interface{} {
Example: example.name,
Kind: example.d.Kind,
OutputFormat: example.f.Name,
- Suffix: example.f.MediaType.Suffix,
+ Suffix: example.f.MediaType.Suffix(),
Layouts: makeLayoutsPresentable(layouts)})
}
diff --git a/output/layout.go b/output/layout.go
index f83490d81..5d72938af 100644
--- a/output/layout.go
+++ b/output/layout.go
@@ -47,7 +47,7 @@ type LayoutHandler struct {
type layoutCacheKey struct {
d LayoutDescriptor
- f Format
+ f string
}
// NewLayoutHandler creates a new LayoutHandler.
@@ -60,7 +60,7 @@ func NewLayoutHandler() *LayoutHandler {
func (l *LayoutHandler) For(d LayoutDescriptor, f Format) ([]string, error) {
// We will get lots of requests for the same layouts, so avoid recalculations.
- key := layoutCacheKey{d, f}
+ key := layoutCacheKey{d, f.Name}
l.mu.RLock()
if cacheVal, found := l.cache[key]; found {
l.mu.RUnlock()
@@ -209,7 +209,7 @@ func (l *layoutBuilder) resolveVariations() []string {
"TYPE", typeVar,
"LAYOUT", layoutVar,
"VARIATIONS", variation,
- "EXTENSION", l.f.MediaType.Suffix,
+ "EXTENSION", l.f.MediaType.Suffix(),
))
}
}
diff --git a/output/layout_test.go b/output/layout_test.go
index 4b958e9ff..e5f2b5b6f 100644
--- a/output/layout_test.go
+++ b/output/layout_test.go
@@ -27,11 +27,11 @@ import (
func TestLayout(t *testing.T) {
noExtNoDelimMediaType := media.TextType
- noExtNoDelimMediaType.Suffix = ""
+ noExtNoDelimMediaType.Suffixes = nil
noExtNoDelimMediaType.Delimiter = ""
noExtMediaType := media.TextType
- noExtMediaType.Suffix = ""
+ noExtMediaType.Suffixes = nil
var (
ampType = Format{
@@ -47,6 +47,7 @@ func TestLayout(t *testing.T) {
MediaType: noExtNoDelimMediaType,
BaseName: "_redirects",
}
+
noExt = Format{
Name: "NEX",
MediaType: noExtMediaType,
diff --git a/output/outputFormat.go b/output/outputFormat.go
index 877850160..30bf903b4 100644
--- a/output/outputFormat.go
+++ b/output/outputFormat.go
@@ -178,7 +178,7 @@ func (formats Formats) Less(i, j int) bool { return formats[i].Name < formats[j]
// The lookup is case insensitive.
func (formats Formats) GetBySuffix(suffix string) (f Format, found bool) {
for _, ff := range formats {
- if strings.EqualFold(suffix, ff.MediaType.Suffix) {
+ if strings.EqualFold(suffix, ff.MediaType.Suffix()) {
if found {
// ambiguous
found = false
@@ -331,7 +331,7 @@ func decode(mediaTypes media.Types, input, output interface{}) error {
}
func (formats Format) BaseFilename() string {
- return formats.BaseName + "." + formats.MediaType.Suffix
+ return formats.BaseName + formats.MediaType.FullSuffix()
}
func (formats Format) MarshalJSON() ([]byte, error) {
diff --git a/output/outputFormat_test.go b/output/outputFormat_test.go
index b800d1a36..5d0620fa9 100644
--- a/output/outputFormat_test.go
+++ b/output/outputFormat_test.go
@@ -93,11 +93,11 @@ func TestGetFormatByExt(t *testing.T) {
func TestGetFormatByFilename(t *testing.T) {
noExtNoDelimMediaType := media.TextType
- noExtNoDelimMediaType.Suffix = ""
+ noExtNoDelimMediaType.OldSuffix = ""
noExtNoDelimMediaType.Delimiter = ""
noExtMediaType := media.TextType
- noExtMediaType.Suffix = ""
+ noExtMediaType.OldSuffix = ""
var (
noExtDelimFormat = Format{