Skip to content

Commit

Permalink
config: Fix uglyurls map parse
Browse files Browse the repository at this point in the history
Fixes #12926
  • Loading branch information
akkuman authored and bep committed Oct 14, 2024
1 parent 57151a5 commit ea633dd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions config/allconfig/allconfig_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,21 @@ title: "p3"
b.AssertFileExists("public/page/1/index.html", false)
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)
}
2 changes: 2 additions & 0 deletions config/allconfig/alldecoders.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ var allDecoderSetups = map[string]decodeWeight{
p.c.UglyURLs = vv
case string:
p.c.UglyURLs = vv == "true"
case maps.Params:
p.c.UglyURLs = cast.ToStringMapBool(maps.CleanConfigStringMap(vv))
default:
p.c.UglyURLs = cast.ToStringMapBool(v)
}
Expand Down

0 comments on commit ea633dd

Please sign in to comment.