mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-19 21:21:39 +02:00
@@ -965,3 +965,27 @@ All.
|
||||
|
||||
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 {
|
||||
pcfg.Fields = make(maps.Params)
|
||||
}
|
||||
if pcfg.Params == nil {
|
||||
pcfg.Params = make(maps.Params)
|
||||
}
|
||||
for k, v := range m {
|
||||
switch strings.ToLower(k) {
|
||||
case "_target", "target":
|
||||
@@ -186,9 +189,6 @@ func mapToPageMatcherParamsConfig(m map[string]any) (PageMatcherParamsConfig, er
|
||||
}
|
||||
pcfg.Target = target
|
||||
case "params":
|
||||
if pcfg.Params == nil {
|
||||
pcfg.Params = make(maps.Params)
|
||||
}
|
||||
params := maps.ToStringMap(v)
|
||||
for k, v := range params {
|
||||
if _, found := pcfg.Params[k]; !found {
|
||||
@@ -196,7 +196,6 @@ func mapToPageMatcherParamsConfig(m map[string]any) (PageMatcherParamsConfig, er
|
||||
}
|
||||
}
|
||||
default:
|
||||
|
||||
pcfg.Fields[k] = v
|
||||
}
|
||||
}
|
||||
|
@@ -89,6 +89,7 @@ func TestPageMatcher(t *testing.T) {
|
||||
return v
|
||||
}
|
||||
c.Assert(fn(map[string]any{"_target": map[string]any{"kind": "page"}, "foo": "bar"}), qt.DeepEquals, PageMatcherParamsConfig{
|
||||
Params: maps.Params{},
|
||||
Fields: maps.Params{
|
||||
"foo": "bar",
|
||||
},
|
||||
|
Reference in New Issue
Block a user