aboutsummaryrefslogtreecommitdiffhomepage
path: root/tpl
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-03-13 11:19:06 +0100
committerBjørn Erik Pedersen <[email protected]>2024-03-13 18:59:50 +0200
commit9e9b1f110cbcfd2182693d59243b36e6a4cc165d (patch)
tree01a03801843082347ab764c98ef9ca3a18624321 /tpl
parentdc6a292133bf3249f1741a7624075b0782b16f84 (diff)
downloadhugo-9e9b1f110cbcfd2182693d59243b36e6a4cc165d.tar.gz
hugo-9e9b1f110cbcfd2182693d59243b36e6a4cc165d.zip
Fix Name for nested resourced fetched in resources.ByName and similar
Fixes #12214
Diffstat (limited to 'tpl')
-rw-r--r--tpl/resources/resources_integration_test.go67
1 files changed, 67 insertions, 0 deletions
diff --git a/tpl/resources/resources_integration_test.go b/tpl/resources/resources_integration_test.go
index b4630b6a2..6bc872bca 100644
--- a/tpl/resources/resources_integration_test.go
+++ b/tpl/resources/resources_integration_test.go
@@ -171,3 +171,70 @@ Home.
b.AssertFileExists("public/a.txt", true) // failing test
b.AssertFileExists("public/b.txt", true) // failing test
}
+
+func TestGlobalResourcesNotPublishedRegressionIssue12214(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+disableKinds = ['page','rss','section','sitemap','taxonomy','term']
+-- assets/files/a.txt --
+I am a.txt
+-- assets/files/b.txt --
+I am b.txt
+-- assets/files/c.txt --
+I am c.txt
+-- assets/files/C.txt --
+I am C.txt
+-- layouts/index.html --
+Home.
+{{ with resources.ByType "text" }}
+ {{ with .Get "files/a.txt" }}
+ {{ .Publish }}
+ files/a.txt: {{ .Name }}
+ {{ end }}
+ {{ with .Get "/files/a.txt" }}
+ /files/a.txt: {{ .Name }}
+ {{ end }}
+ {{ with .GetMatch "files/*b*" }}
+ {{ .Publish }}
+ files/*b*: {{ .Name }}
+ {{ end }}
+ {{ with .GetMatch "files/C*" }}
+ {{ .Publish }}
+ files/C*: {{ .Name }}
+ {{ end }}
+ {{ with .GetMatch "files/c*" }}
+ {{ .Publish }}
+ files/c*: {{ .Name }}
+ {{ end }}
+ {{ with .GetMatch "/files/c*" }}
+ /files/c*: {{ .Name }}
+ {{ end }}
+ {{ with .Match "files/C*" }}
+ match files/C*: {{ len . }}|
+ {{ end }}
+ {{ with .Match "/files/C*" }}
+ match /files/C*: {{ len . }}|
+{{ end }}
+{{ end }}
+`
+
+ b := hugolib.Test(t, files)
+
+ b.AssertFileContent("public/index.html", `
+files/a.txt: /files/a.txt
+# There are both C.txt and c.txt in the assets, but the Glob matching is case insensitive, so GetMatch returns the first.
+files/C*: /files/C.txt
+files/c*: /files/C.txt
+files/*b*: /files/b.txt
+/files/c*: /files/C.txt
+/files/a.txt: /files/a.txt
+match files/C*: 2|
+match /files/C*: 2|
+ `)
+
+ b.AssertFileContent("public/files/a.txt", "I am a.txt")
+ b.AssertFileContent("public/files/b.txt", "I am b.txt")
+ b.AssertFileContent("public/files/C.txt", "I am C.txt")
+}