]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Fix section page resource not published if resource filename partially matches conten...
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 7 Mar 2024 07:34:00 +0000 (08:34 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 7 Mar 2024 08:50:50 +0000 (09:50 +0100)
Fixes #12198

hugolib/content_map_page.go
hugolib/content_map_test.go

index ddc22bb66521556bcdef31a536078a5db91e16c0..f20a30abeaead49ce8eb3d629d3820e996318044 100644 (file)
@@ -485,7 +485,7 @@ func (m *pageMap) forEachResourceInPage(
        rw.Handle = func(resourceKey string, n contentNodeI, match doctree.DimensionFlag) (bool, error) {
                if isBranch {
                        ownerKey, _ := m.treePages.LongestPrefixAll(resourceKey)
-                       if ownerKey != keyPage {
+                       if ownerKey != keyPage && path.Dir(ownerKey) != path.Dir(resourceKey) {
                                // Stop walking downwards, someone else owns this resource.
                                rw.SkipPrefix(ownerKey + "/")
                                return false, nil
index e043d9363852ba16b4dc7aacec5f19f98bca8900..85e2c60560cbd92af44f001a94c31566668ace7a 100644 (file)
@@ -326,3 +326,35 @@ R: {{ with $r }}{{ .Content }}{{ end }}|Len: {{ len $bundle.Resources }}|$
                b.AssertFileContent("public/index.html", "R: Data 1.txt|", "Len: 1|")
        }
 }
+
+func TestBundleResourcesNoPublishedIssue12198(t *testing.T) {
+       t.Parallel()
+
+       files := `
+-- hugo.toml --
+disableKinds = ['home','rss','sitemap','taxonomy','term']
+-- content/s1/p1.md --
+---
+title: p1
+---
+-- content/s1/foo.txt --
+foo.txt
+-- content/s1/p1.txt --
+p1.txt
+-- content/s1/p1-foo.txt --
+p1-foo.txt
+-- layouts/_default/list.html --
+{{.Title }}|
+-- layouts/_default/single.html --
+{{.Title }}|
+       `
+
+       b := Test(t, files)
+       b.Build()
+
+       b.AssertFileExists("public/s1/index.html", true)
+       b.AssertFileExists("public/s1/foo.txt", true)
+       b.AssertFileExists("public/s1/p1.txt", true)     // failing test
+       b.AssertFileExists("public/s1/p1-foo.txt", true) // failing test
+       b.AssertFileExists("public/s1/p1/index.html", true)
+}