]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Fix rebuild when adding a bundle with space in name
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 21 Feb 2024 16:04:32 +0000 (17:04 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 21 Feb 2024 16:49:15 +0000 (17:49 +0100)
Fixes #12092

hugolib/pages_capture.go
hugolib/rebuild_test.go

index b9d7a0ae1316f3c81352f97c2915512c2943ac34..4328978db1cf15f4d1a95378b48e03b00dbac5cf 100644 (file)
@@ -195,9 +195,9 @@ func (c *pagesCollector) collectDir(dirPath *paths.Path, isDir bool, inFilter fu
        var dpath string
        if dirPath != nil {
                if isDir {
-                       dpath = filepath.FromSlash(dirPath.Path())
+                       dpath = filepath.FromSlash(dirPath.Unnormalized().Path())
                } else {
-                       dpath = filepath.FromSlash(dirPath.Dir())
+                       dpath = filepath.FromSlash(dirPath.Unnormalized().Dir())
                }
        }
 
index 54d6888c09305f40ca0c63d5badc3df2124f81f1..98a8d0949f88e0317abfb298e62d65fcc91ca927 100644 (file)
@@ -305,6 +305,29 @@ Pages: {{ range .RegularPages }}{{ .RelPermalink }}|{{ end }}$
        b.AssertFileContent("public/index.html", "Pages: /p1/|/p2/|$")
 }
 
+func TestRebuildAddPageWithSpaceListPagesInHome(t *testing.T) {
+       files := `
+-- hugo.toml --
+baseURL = "https://example.com"
+disableLiveReload = true
+-- content/asection/s1.md --
+-- content/p1.md --
+---
+title: "P1"
+weight: 1
+---
+-- layouts/_default/single.html --
+Single: {{ .Title }}|{{ .Content }}|
+-- layouts/index.html --
+Pages: {{ range .RegularPages }}{{ .RelPermalink }}|{{ end }}$
+`
+
+       b := TestRunning(t, files)
+       b.AssertFileContent("public/index.html", "Pages: /p1/|$")
+       b.AddFiles("content/test test/index.md", ``).Build()
+       b.AssertFileContent("public/index.html", "Pages: /p1/|/test-test/|$")
+}
+
 func TestRebuildScopedToOutputFormat(t *testing.T) {
        files := `
 -- hugo.toml --