summaryrefslogtreecommitdiffstats
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-01-30 10:42:24 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-01-30 20:12:03 +0100
commit80595bbe3e7901ecd6200e59d43af142c3c85b6b (patch)
tree5745149392c7a542891000a7740a7b7184a79226 /hugolib
parentafee781f03df4305698bf4b6991cd10e996515c5 (diff)
Fix recent regression .Resources.Get for resources with spaces in filename
Fixes #11944
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/content_map_page.go2
-rw-r--r--hugolib/content_map_test.go19
2 files changed, 20 insertions, 1 deletions
diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go
index 9fee74003..9accd190e 100644
--- a/hugolib/content_map_page.go
+++ b/hugolib/content_map_page.go
@@ -1548,7 +1548,7 @@ func (sa *sitePagesAssembler) assembleResources() error {
return false, nil
}
- relPathOriginal := rs.path.PathRel(ps.m.pathInfo)
+ relPathOriginal := rs.path.Unmormalized().PathRel(ps.m.pathInfo.Unmormalized())
relPath := rs.path.BaseRel(ps.m.pathInfo)
var targetBasePaths []string
diff --git a/hugolib/content_map_test.go b/hugolib/content_map_test.go
index a41b2aae9..7843ad285 100644
--- a/hugolib/content_map_test.go
+++ b/hugolib/content_map_test.go
@@ -280,3 +280,22 @@ P1: {{ $p1.Title }}|{{ $p1.Params.foo }}|{{ $p1.File.Filename }}|
filepath.FromSlash("P1: P1 md|md|/content/p1.md|"),
)
}
+
+// Issue #11944
+func TestBundleResourcesGetWithSpacesInFilename(t *testing.T) {
+ files := `
+-- hugo.toml --
+baseURL = "https://example.com"
+disableKinds = ["taxonomy", "term"]
+-- content/bundle/index.md --
+-- content/bundle/data with Spaces.txt --
+Data.
+-- layouts/index.html --
+{{ $bundle := site.GetPage "bundle" }}
+{{ $r := $bundle.Resources.Get "data with Spaces.txt" }}
+R: {{ with $r }}{{ .Content }}{{ end }}|
+`
+ b := Test(t, files)
+
+ b.AssertFileContent("public/index.html", "R: Data.")
+}