]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
config: Fix uglyurls map parse
authorAkkuman <akkumans@qq.com>
Sat, 12 Oct 2024 07:48:19 +0000 (15:48 +0800)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 14 Oct 2024 08:03:44 +0000 (10:03 +0200)
Fixes #12926

config/allconfig/allconfig_integration_test.go
config/allconfig/alldecoders.go

index debdff65011af3ceb7597486b1a9cd1d575d2f5a..1b677884f59a547e444b3267f7327904dab02269 100644 (file)
@@ -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)
+}
index 45cdd0de6a7476a2f957931c762991c2f5cfd800..60e571999408400501b00d0ab476c7f3e5b0dcaa 100644 (file)
@@ -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)
                        }