Detect now invalid path patterns in cascade

Closes #11977
This commit is contained in:
Bjørn Erik Pedersen
2024-02-03 13:09:53 +01:00
parent a66480f70c
commit 058f230a1b
7 changed files with 72 additions and 15 deletions

View File

@@ -671,3 +671,32 @@ S1|p1:|p2:p2|
`)
})
}
// Issue 11977.
func TestCascadeExtensionInPath(t *testing.T) {
files := `
-- hugo.toml --
baseURL = "https://example.org"
[languages]
[languages.en]
weight = 1
[languages.de]
-- content/_index.de.md --
+++
[[cascade]]
[cascade.params]
foo = 'bar'
[cascade._target]
path = '/posts/post-1.de.md'
+++
-- content/posts/post-1.de.md --
---
title: "Post 1"
---
-- layouts/_default/single.html --
{{ .Title }}|{{ .Params.foo }}$
`
b, err := TestE(t, files)
b.Assert(err, qt.IsNotNil)
b.AssertLogContains(`cascade target path "/posts/post-1.de.md" looks like a path with an extension; since Hugo v0.123.0 this will not match anything, see https://gohugo.io/methods/page/path/`)
}