Skip to content

Commit

Permalink
Fix recent regression .Resources.Get for resources with spaces in fil…
Browse files Browse the repository at this point in the history
…ename

Fixes #11944
  • Loading branch information
bep committed Jan 30, 2024
1 parent 686598f commit 7ea2bae
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hugolib/content_map_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions hugolib/content_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}

0 comments on commit 7ea2bae

Please sign in to comment.