diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-03-01 11:47:16 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-03-01 13:34:05 +0100 |
commit | 7023cf0f07d07bd943404d88d5fc8f3c5f7c9cc2 (patch) | |
tree | dceca2aff42032c251c427c42ded34d2b54ea48b /tpl | |
parent | 9dfa9e70e6ac56cfbb875caf5fed412eb2b22d82 (diff) | |
download | hugo-7023cf0f07d07bd943404d88d5fc8f3c5f7c9cc2.tar.gz hugo-7023cf0f07d07bd943404d88d5fc8f3c5f7c9cc2.zip |
Fix resources.GetMatch, resources.Match, and resources.ByType to they don't normalize permalinks
Fixes #12182
Diffstat (limited to 'tpl')
-rw-r--r-- | tpl/resources/resources_integration_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tpl/resources/resources_integration_test.go b/tpl/resources/resources_integration_test.go index 5a3c29666..d72b13507 100644 --- a/tpl/resources/resources_integration_test.go +++ b/tpl/resources/resources_integration_test.go @@ -116,3 +116,30 @@ Empty string not found `) } + +func TestResourcesGettersShouldNotNormalizePermalinks(t *testing.T) { + t.Parallel() + + files := ` +-- config.toml -- +baseURL = "http://example.com/" +-- assets/401K Prospectus.txt -- +Prospectus. +-- layouts/index.html -- +{{ $name := "401K Prospectus.txt" }} +Get: {{ with resources.Get $name }}{{ .RelPermalink }}|{{ .Permalink }}|{{ end }} +GetMatch: {{ with resources.GetMatch $name }}{{ .RelPermalink }}|{{ .Permalink }}|{{ end }} +Match: {{ with (index (resources.Match $name) 0) }}{{ .RelPermalink }}|{{ .Permalink }}|{{ end }} +ByType: {{ with (index (resources.ByType "text") 0) }}{{ .RelPermalink }}|{{ .Permalink }}|{{ end }} + ` + + b := hugolib.Test(t, files) + + b.AssertFileContent("public/index.html", ` +Get: /401K%20Prospectus.txt|http://example.com/401K%20Prospectus.txt| +GetMatch: /401K%20Prospectus.txt|http://example.com/401K%20Prospectus.txt| +Match: /401K%20Prospectus.txt|http://example.com/401K%20Prospectus.txt| +ByType: /401K%20Prospectus.txt|http://example.com/401K%20Prospectus.txt| + + `) +} |