ref: 5be0448635fdf5fe6b1ee673e869f2b9baf1a5c6
parent: 1f55cb767db5839ce8fd1de64cda0959d6bfac58
author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
date: Tue Jun 6 05:15:42 EDT 2017
hugolib: Fix disablePathToLower regression Fixes #3374
--- a/hugolib/page_paths.go
+++ b/hugolib/page_paths.go
@@ -85,7 +85,7 @@
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,
}
--- a/hugolib/page_test.go
+++ b/hugolib/page_test.go
@@ -1417,30 +1417,32 @@
}
}
-// 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("disablePathToLower", disablePathToLower)+ cfg.Set("paginate", 1)- cfg.Set("uglyURLs", uglyURLs)- 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"
@@ -1447,40 +1449,58 @@
---
# doc1
*some content*`, i))
- }
+ }
- s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{})- require.Len(t, s.RegularPages, 3)
+ writeSource(t, fs, filepath.Join("content", "Blog", "Blog1.md"),+ fmt.Sprintf(`---
+title: "testBlog"
+tags:
+- "Blog"
+---
+# doc1
+*some blog content*`))
- pathFunc := func(s string) string {- if uglyURLs {- return strings.Replace(s, "/index.html", ".html", 1)
+ 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)
+ }
+ 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())
+ }
+
+ })
+ }
}
}
--
⑨