config: Fix uglyurls map parse

Fixes #12926
This commit is contained in:
Akkuman 2024-10-12 15:48:19 +08:00 committed by Bjørn Erik Pedersen
parent 57151a5e91
commit ea633dd809
2 changed files with 20 additions and 0 deletions

View file

@ -160,3 +160,21 @@ title: "p3"
b.AssertFileExists("public/page/1/index.html", false) b.AssertFileExists("public/page/1/index.html", false)
b.AssertFileContent("public/page/2/index.html", "pagination-default") b.AssertFileContent("public/page/2/index.html", "pagination-default")
} }
func TestMapUglyURLs(t *testing.T) {
files := `
-- hugo.toml --
[uglyurls]
posts = true
`
b := hugolib.Test(t, files)
c := b.H.Configs.Base
mapUglyURLs, isMap := c.UglyURLs.(map[string]bool)
b.Assert(isMap, qt.Equals, true)
b.Assert(mapUglyURLs["posts"], qt.Equals, true)
}

View file

@ -419,6 +419,8 @@ var allDecoderSetups = map[string]decodeWeight{
p.c.UglyURLs = vv p.c.UglyURLs = vv
case string: case string:
p.c.UglyURLs = vv == "true" p.c.UglyURLs = vv == "true"
case maps.Params:
p.c.UglyURLs = cast.ToStringMapBool(maps.CleanConfigStringMap(vv))
default: default:
p.c.UglyURLs = cast.ToStringMapBool(v) p.c.UglyURLs = cast.ToStringMapBool(v)
} }