resources/page: Respect disablePathToLower for permalink tokens

Fixes #13755
This commit is contained in:
Joe Mooring
2025-05-28 21:57:48 -07:00
committed by Bjørn Erik Pedersen
parent bff5d19121
commit 843ffeb48d
2 changed files with 28 additions and 1 deletions

View File

@@ -311,7 +311,7 @@ func (l PermalinkExpander) pageToPermalinkSections(p Page, _ string) (string, er
// pageToPermalinkContentBaseName returns the URL-safe form of the content base name. // pageToPermalinkContentBaseName returns the URL-safe form of the content base name.
func (l PermalinkExpander) pageToPermalinkContentBaseName(p Page, _ string) (string, error) { func (l PermalinkExpander) pageToPermalinkContentBaseName(p Page, _ string) (string, error) {
return l.urlize(p.PathInfo().BaseNameNoIdentifier()), nil return l.urlize(p.PathInfo().Unnormalized().BaseNameNoIdentifier()), nil
} }
// pageToPermalinkSlugOrContentBaseName returns the URL-safe form of the slug, content base name. // pageToPermalinkSlugOrContentBaseName returns the URL-safe form of the slug, content base name.

View File

@@ -14,6 +14,7 @@
package page_test package page_test
import ( import (
"strings"
"testing" "testing"
"github.com/bep/logg" "github.com/bep/logg"
@@ -343,3 +344,29 @@ slug: "c2slug"
b.AssertFileContent("public/myc/c1/index.html", "C1|/myc/c1/|term|") b.AssertFileContent("public/myc/c1/index.html", "C1|/myc/c1/|term|")
b.AssertFileContent("public/myc/c2slug/index.html", "C2|/myc/c2slug/|term|") b.AssertFileContent("public/myc/c2slug/index.html", "C2|/myc/c2slug/|term|")
} }
func TestIssue13755(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
disablePathToLower = false
[permalinks.page]
s1 = "/:contentbasename"
-- content/s1/aBc.md --
---
title: aBc
---
-- layouts/all.html --
{{ .Title }}
`
b := hugolib.Test(t, files)
b.AssertFileExists("public/abc/index.html", true)
files = strings.ReplaceAll(files, "disablePathToLower = false", "disablePathToLower = true")
b = hugolib.Test(t, files)
b.AssertFileExists("public/aBc/index.html", true)
}