mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
2fb40ece5d
commit
671f64b2eb
3 changed files with 41 additions and 1 deletions
|
@ -136,3 +136,42 @@ Sort: [éclair emma xylophone zulu]
|
||||||
ByWeight: alpha|émotion|zulu|
|
ByWeight: alpha|émotion|zulu|
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See #10377
|
||||||
|
func TestPermalinkExpansionSectionsRepeated(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
files := `
|
||||||
|
-- hugo.toml --
|
||||||
|
disableKinds = ["home", "taxonomy", "taxonomyTerm", "sitemap"]
|
||||||
|
[outputs]
|
||||||
|
home = ["HTML"]
|
||||||
|
page = ["HTML"]
|
||||||
|
section = ["HTML"]
|
||||||
|
[outputFormats]
|
||||||
|
[permalinks]
|
||||||
|
posts = '/:sections[1]/:sections[last]/:slug'
|
||||||
|
-- content/posts/_index.md --
|
||||||
|
-- content/posts/a/_index.md --
|
||||||
|
-- content/posts/a/b/_index.md --
|
||||||
|
-- content/posts/a/b/c/_index.md --
|
||||||
|
-- content/posts/a/b/c/d.md --
|
||||||
|
---
|
||||||
|
title: "D"
|
||||||
|
slug: "d"
|
||||||
|
---
|
||||||
|
D
|
||||||
|
-- layouts/_default/single.html --
|
||||||
|
RelPermalink: {{ .RelPermalink }}
|
||||||
|
|
||||||
|
`
|
||||||
|
|
||||||
|
b := hugolib.NewIntegrationTestBuilder(
|
||||||
|
hugolib.IntegrationTestConfig{
|
||||||
|
T: t,
|
||||||
|
TxtarString: files,
|
||||||
|
}).Build()
|
||||||
|
|
||||||
|
b.AssertFileContent("public/a/c/d/index.html", "RelPermalink: /a/c/d/")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -176,7 +176,7 @@ func (l PermalinkExpander) parse(patterns map[string]string) (map[string]func(Pa
|
||||||
// can return a string to go in that position in the page (or an error)
|
// can return a string to go in that position in the page (or an error)
|
||||||
type pageToPermaAttribute func(Page, string) (string, error)
|
type pageToPermaAttribute func(Page, string) (string, error)
|
||||||
|
|
||||||
var attributeRegexp = regexp.MustCompile(`:\w+(\[.+\])?`)
|
var attributeRegexp = regexp.MustCompile(`:\w+(\[.+?\])?`)
|
||||||
|
|
||||||
// validate determines if a PathPattern is well-formed
|
// validate determines if a PathPattern is well-formed
|
||||||
func (l PermalinkExpander) validate(pp string) bool {
|
func (l PermalinkExpander) validate(pp string) bool {
|
||||||
|
|
|
@ -42,6 +42,7 @@ var testdataPermalinks = []struct {
|
||||||
{"/:2006_01_02_15_04_05.000", true, "/2012_04_06_03_01_59.000"}, // Complicated custom date format
|
{"/:2006_01_02_15_04_05.000", true, "/2012_04_06_03_01_59.000"}, // Complicated custom date format
|
||||||
{"/:sections/", true, "/a/b/c/"}, // Sections
|
{"/:sections/", true, "/a/b/c/"}, // Sections
|
||||||
{"/:sections[last]/", true, "/c/"}, // Sections
|
{"/:sections[last]/", true, "/c/"}, // Sections
|
||||||
|
{"/:sections[0]/:sections[last]/", true, "/a/c/"}, // Sections
|
||||||
|
|
||||||
// Failures
|
// Failures
|
||||||
{"/blog/:fred", false, ""},
|
{"/blog/:fred", false, ""},
|
||||||
|
|
Loading…
Reference in a new issue