Fix regression when config for OutputFormat.BaseName is an empty string

Fixes #11000
This commit is contained in:
Bjørn Erik Pedersen
2023-05-23 17:39:49 +02:00
parent d666edad71
commit ed906a86e2
2 changed files with 44 additions and 9 deletions

View File

@@ -32,6 +32,11 @@ type OutputFormatConfig struct {
Format
}
var defaultOutputFormat = Format{
BaseName: "index",
Rel: "alternate",
}
func DecodeConfig(mediaTypes media.Types, in any) (*config.ConfigNamespace[map[string]OutputFormatConfig, Formats], error) {
buildConfig := func(in any) (Formats, any, error) {
f := make(Formats, len(DefaultFormats))
@@ -59,20 +64,12 @@ func DecodeConfig(mediaTypes media.Types, in any) (*config.ConfigNamespace[map[s
continue
}
var newOutFormat Format
newOutFormat := defaultOutputFormat
newOutFormat.Name = k
if err := decode(mediaTypes, v, &newOutFormat); err != nil {
return f, nil, err
}
// We need values for these
if newOutFormat.BaseName == "" {
newOutFormat.BaseName = "index"
}
if newOutFormat.Rel == "" {
newOutFormat.Rel = "alternate"
}
f = append(f, newOutFormat)
}