hugolib: Fix disablePathToLower regression

Fixes #3374
This commit is contained in:
Bjørn Erik Pedersen 2017-06-06 09:15:42 +02:00
parent 1f55cb767d
commit 5be0448635
2 changed files with 67 additions and 47 deletions

View file

@ -85,7 +85,7 @@ func (p *Page) initTargetPathDescriptor() error {
Kind: p.Kind,
Sections: p.sections,
UglyURLs: p.s.Info.uglyURLs,
Dir: filepath.ToSlash(strings.ToLower(p.Source.Dir())),
Dir: filepath.ToSlash(p.Source.Dir()),
URL: p.URLPath.URL,
}

View file

@ -1417,12 +1417,13 @@ func TestShouldBuild(t *testing.T) {
}
}
// Issue #1885 and #2110
func TestDotInPath(t *testing.T) {
// "dot" in path: #1885 and #2110
// disablePathToLower regression: #3374
func TestPathIssues(t *testing.T) {
t.Parallel()
for _, disablePathToLower := range []bool{false, true} {
for _, uglyURLs := range []bool{false, true} {
t.Run(fmt.Sprintf("uglyURLs=%t", uglyURLs), func(t *testing.T) {
t.Run(fmt.Sprintf("disablePathToLower=%t,uglyURLs=%t", disablePathToLower, uglyURLs), func(t *testing.T) {
cfg, fs := newTestCfg()
th := testHelper{cfg, fs, t}
@ -1432,6 +1433,7 @@ func TestDotInPath(t *testing.T) {
})
cfg.Set("uglyURLs", uglyURLs)
cfg.Set("disablePathToLower", disablePathToLower)
cfg.Set("paginate", 1)
writeSource(t, fs, filepath.Join("layouts", "_default", "single.html"), "<html><body>{{.Content}}</body></html>")
@ -1449,8 +1451,17 @@ tags:
*some content*`, i))
}
writeSource(t, fs, filepath.Join("content", "Blog", "Blog1.md"),
fmt.Sprintf(`---
title: "testBlog"
tags:
- "Blog"
---
# doc1
*some blog content*`))
s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{})
require.Len(t, s.RegularPages, 3)
require.Len(t, s.RegularPages, 4)
pathFunc := func(s string) string {
if uglyURLs {
@ -1459,6 +1470,14 @@ tags:
return s
}
blog := "blog"
if disablePathToLower {
blog = "Blog"
}
th.assertFileContent(pathFunc("public/"+blog+"/"+blog+"1/index.html"), "some blog content")
th.assertFileContent(pathFunc("public/post/test0.dot/index.html"), "some content")
if uglyURLs {
@ -1483,6 +1502,7 @@ tags:
})
}
}
}
func BenchmarkParsePage(b *testing.B) {
s := newTestSite(b)