]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
resources/page: Respect disablePathToLower for permalink tokens
authorJoe Mooring <joe.mooring@veriphor.com>
Thu, 29 May 2025 04:57:48 +0000 (21:57 -0700)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 29 May 2025 20:10:03 +0000 (22:10 +0200)
Fixes #13755

resources/page/permalinks.go
resources/page/permalinks_integration_test.go

index 953f4a2e8e0eccb0cb9b382dcce7780038f47780..f8cbcd62c00cde6230ffeeee4808749c4dfd372a 100644 (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.
 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.
index 6ef450edd0ddead28a974f32888a38a8a25759c2..c865e27048e6fa0c66968344b7014114e1279eb8 100644 (file)
@@ -14,6 +14,7 @@
 package page_test
 
 import (
+       "strings"
        "testing"
 
        "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/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)
+}