mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
@@ -965,3 +965,27 @@ All.
|
|||||||
|
|
||||||
b.AssertLogContains("! WARN")
|
b.AssertLogContains("! WARN")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCascadeNilMapIssue13853(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
files := `
|
||||||
|
-- hugo.toml --
|
||||||
|
-- content/test/_index.md --
|
||||||
|
---
|
||||||
|
title: Test
|
||||||
|
cascade:
|
||||||
|
- build:
|
||||||
|
list: local
|
||||||
|
target:
|
||||||
|
path: '{/test/**}'
|
||||||
|
- params:
|
||||||
|
title: 'Test page'
|
||||||
|
target:
|
||||||
|
path: '{/test/**}'
|
||||||
|
---
|
||||||
|
`
|
||||||
|
|
||||||
|
// Just verify that it does not panic.
|
||||||
|
_ = Test(t, files)
|
||||||
|
}
|
||||||
|
@@ -177,6 +177,9 @@ func mapToPageMatcherParamsConfig(m map[string]any) (PageMatcherParamsConfig, er
|
|||||||
if pcfg.Fields == nil {
|
if pcfg.Fields == nil {
|
||||||
pcfg.Fields = make(maps.Params)
|
pcfg.Fields = make(maps.Params)
|
||||||
}
|
}
|
||||||
|
if pcfg.Params == nil {
|
||||||
|
pcfg.Params = make(maps.Params)
|
||||||
|
}
|
||||||
for k, v := range m {
|
for k, v := range m {
|
||||||
switch strings.ToLower(k) {
|
switch strings.ToLower(k) {
|
||||||
case "_target", "target":
|
case "_target", "target":
|
||||||
@@ -186,9 +189,6 @@ func mapToPageMatcherParamsConfig(m map[string]any) (PageMatcherParamsConfig, er
|
|||||||
}
|
}
|
||||||
pcfg.Target = target
|
pcfg.Target = target
|
||||||
case "params":
|
case "params":
|
||||||
if pcfg.Params == nil {
|
|
||||||
pcfg.Params = make(maps.Params)
|
|
||||||
}
|
|
||||||
params := maps.ToStringMap(v)
|
params := maps.ToStringMap(v)
|
||||||
for k, v := range params {
|
for k, v := range params {
|
||||||
if _, found := pcfg.Params[k]; !found {
|
if _, found := pcfg.Params[k]; !found {
|
||||||
@@ -196,7 +196,6 @@ func mapToPageMatcherParamsConfig(m map[string]any) (PageMatcherParamsConfig, er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
||||||
pcfg.Fields[k] = v
|
pcfg.Fields[k] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -89,6 +89,7 @@ func TestPageMatcher(t *testing.T) {
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
c.Assert(fn(map[string]any{"_target": map[string]any{"kind": "page"}, "foo": "bar"}), qt.DeepEquals, PageMatcherParamsConfig{
|
c.Assert(fn(map[string]any{"_target": map[string]any{"kind": "page"}, "foo": "bar"}), qt.DeepEquals, PageMatcherParamsConfig{
|
||||||
|
Params: maps.Params{},
|
||||||
Fields: maps.Params{
|
Fields: maps.Params{
|
||||||
"foo": "bar",
|
"foo": "bar",
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user