summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-06-06 09:15:42 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-06-06 09:15:42 +0200
commit5be0448635fdf5fe6b1ee673e869f2b9baf1a5c6 (patch)
treef9b256cda354507d20962a17c1d3d06384cd2348
parent1f55cb767db5839ce8fd1de64cda0959d6bfac58 (diff)
hugolib: Fix disablePathToLower regression
Fixes #3374
-rw-r--r--hugolib/page_paths.go2
-rw-r--r--hugolib/page_test.go108
2 files changed, 65 insertions, 45 deletions
diff --git a/hugolib/page_paths.go b/hugolib/page_paths.go
index 1fe8ea599..0f5add27d 100644
--- a/hugolib/page_paths.go
+++ b/hugolib/page_paths.go
@@ -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,
}
diff --git a/hugolib/page_test.go b/hugolib/page_test.go
index d24bd2f96..95a3f1efd 100644
--- a/hugolib/page_test.go
+++ b/hugolib/page_test.go
@@ -1417,70 +1417,90 @@ 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("disablePathToLower=%t,uglyURLs=%t", disablePathToLower, uglyURLs), func(t *testing.T) {
- for _, uglyURLs := range []bool{false, true} {
- t.Run(fmt.Sprintf("uglyURLs=%t", uglyURLs), func(t *testing.T) {
+ cfg, fs := newTestCfg()
+ th := testHelper{cfg, fs, t}
- cfg, fs := newTestCfg()
- th := testHelper{cfg, fs, t}
+ cfg.Set("permalinks", map[string]string{
+ "post": ":section/:title",
+ })
- cfg.Set("permalinks", map[string]string{
- "post": ":section/:title",
- })
-
- cfg.Set("uglyURLs", uglyURLs)
- cfg.Set("paginate", 1)
+ 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>")
- writeSource(t, fs, filepath.Join("layouts", "_default", "list.html"),
- "<html><body>P{{.Paginator.PageNumber}}|URL: {{.Paginator.URL}}|{{ if .Paginator.HasNext }}Next: {{.Paginator.Next.URL }}{{ end }}</body></html>")
+ writeSource(t, fs, filepath.Join("layouts", "_default", "single.html"), "<html><body>{{.Content}}</body></html>")
+ writeSource(t, fs, filepath.Join("layouts", "_default", "list.html"),
+ "<html><body>P{{.Paginator.PageNumber}}|URL: {{.Paginator.URL}}|{{ if .Paginator.HasNext }}Next: {{.Paginator.Next.URL }}{{ end }}</body></html>")
- for i := 0; i < 3; i++ {
- writeSource(t, fs, filepath.Join("content", "post", fmt.Sprintf("doc%d.md", i)),
- fmt.Sprintf(`---
+ for i := 0; i < 3; i++ {
+ writeSource(t, fs, filepath.Join("content", "post", fmt.Sprintf("doc%d.md", i)),
+ fmt.Sprintf(`---
title: "test%d.dot"
tags:
- ".net"
---
# doc1
*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)
+ s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{})
+ require.Len(t, s.RegularPages, 4)
- pathFunc := func(s string) string {
- if uglyURLs {
- return strings.Replace(s, "/index.html", ".html", 1)
+ pathFunc := func(s string) string {
+ if uglyURLs {
+ return strings.Replace(s, "/index.html", ".html", 1)
+ }
+ return s
}
- return s
- }
- th.assertFileContent(pathFunc("public/post/test0.dot/index.html"), "some content")
+ blog := "blog"
- if uglyURLs {
- th.assertFileContent("public/post/page/1.html", `canonical" href="/post.html"/`)
- th.assertFileContent("public/post.html", `<body>P1|URL: /post.html|Next: /post/page/2.html</body>`)
- th.assertFileContent("public/post/page/2.html", `<body>P2|URL: /post/page/2.html|Next: /post/page/3.html</body>`)
- } else {
- th.assertFileContent("public/post/page/1/index.html", `canonical" href="/post/"/`)
- th.assertFileContent("public/post/index.html", `<body>P1|URL: /post/|Next: /post/page/2/</body>`)
- th.assertFileContent("public/post/page/2/index.html", `<body>P2|URL: /post/page/2/|Next: /post/page/3/</body>`)
- th.assertFileContent("public/tags/.net/index.html", `<body>P1|URL: /tags/.net/|Next: /tags/.net/page/2/</body>`)
+ if disablePathToLower {
+ blog = "Blog"
+ }
- }
+ th.assertFileContent(pathFunc("public/"+blog+"/"+blog+"1/index.html"), "some blog content")
- p := s.RegularPages[0]
- if uglyURLs {
- require.Equal(t, "/post/test0.dot.html", p.RelPermalink())
- } else {
- require.Equal(t, "/post/test0.dot/", p.RelPermalink())
- }
+ th.assertFileContent(pathFunc("public/post/test0.dot/index.html"), "some content")
+
+ if uglyURLs {
+ th.assertFileContent("public/post/page/1.html", `canonical" href="/post.html"/`)
+ th.assertFileContent("public/post.html", `<body>P1|URL: /post.html|Next: /post/page/2.html</body>`)
+ th.assertFileContent("public/post/page/2.html", `<body>P2|URL: /post/page/2.html|Next: /post/page/3.html</body>`)
+ } else {
+ th.assertFileContent("public/post/page/1/index.html", `canonical" href="/post/"/`)
+ th.assertFileContent("public/post/index.html", `<body>P1|URL: /post/|Next: /post/page/2/</body>`)
+ th.assertFileContent("public/post/page/2/index.html", `<body>P2|URL: /post/page/2/|Next: /post/page/3/</body>`)
+ th.assertFileContent("public/tags/.net/index.html", `<body>P1|URL: /tags/.net/|Next: /tags/.net/page/2/</body>`)
+
+ }
+
+ p := s.RegularPages[0]
+ if uglyURLs {
+ require.Equal(t, "/post/test0.dot.html", p.RelPermalink())
+ } else {
+ require.Equal(t, "/post/test0.dot/", p.RelPermalink())
+ }
- })
+ })
+ }
}
}