ref: 72ba6d633d2a24d03bf16d927d7b87a20c28fda6
parent: 3e87d7a86e5dcd244dd713c8712a26f51f02be87
author: Anton Ageev <antage@gmail.com>
date: Sat Feb 1 23:58:14 EST 2014
Fix permalink bug in uglyurls mode (refs #187).
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -277,7 +277,8 @@
if len(pSlug) > 0 { if p.Site.Config != nil && p.Site.Config.UglyUrls {- permalink = path.Join(dir, p.Slug, p.Extension)
+ filename := fmt.Sprintf("%s.%s", p.Slug, p.Extension)+ permalink = path.Join(dir, filename)
} else {permalink = path.Join(dir, p.Slug) + "/"
}
--- a/hugolib/page_permalink_test.go
+++ b/hugolib/page_permalink_test.go
@@ -11,14 +11,20 @@
dir string
base template.URL
slug string
+ uglyurls bool
expectedAbs string
expectedRel string
}{- {"x/y/z/boofar.md", "x/y/z", "", "", "/x/y/z/boofar", "/x/y/z/boofar"},- {"x/y/z/boofar.md", "x/y/z/", "", "", "/x/y/z/boofar", "/x/y/z/boofar"},- {"x/y/z/boofar.md", "x/y/z/", "", "boofar", "/x/y/z/boofar/", "/x/y/z/boofar/"},- {"x/y/z/boofar.md", "x/y/z", "http://barnew/", "", "http://barnew/x/y/z/boofar", "/x/y/z/boofar"},- {"x/y/z/boofar.md", "x/y/z/", "http://barnew/", "boofar", "http://barnew/x/y/z/boofar/", "/x/y/z/boofar/"},+ {"x/y/z/boofar.md", "x/y/z", "", "", false, "/x/y/z/boofar", "/x/y/z/boofar"},+ {"x/y/z/boofar.md", "x/y/z/", "", "", false, "/x/y/z/boofar", "/x/y/z/boofar"},+ {"x/y/z/boofar.md", "x/y/z/", "", "boofar", false, "/x/y/z/boofar/", "/x/y/z/boofar/"},+ {"x/y/z/boofar.md", "x/y/z", "http://barnew/", "", false, "http://barnew/x/y/z/boofar", "/x/y/z/boofar"},+ {"x/y/z/boofar.md", "x/y/z/", "http://barnew/", "boofar", false, "http://barnew/x/y/z/boofar/", "/x/y/z/boofar/"},+ {"x/y/z/boofar.md", "x/y/z", "", "", true, "/x/y/z/boofar.html", "/x/y/z/boofar.html"},+ {"x/y/z/boofar.md", "x/y/z/", "", "", true, "/x/y/z/boofar.html", "/x/y/z/boofar.html"},+ {"x/y/z/boofar.md", "x/y/z/", "", "boofar", true, "/x/y/z/boofar.html", "/x/y/z/boofar.html"},+ {"x/y/z/boofar.md", "x/y/z", "http://barnew/", "", true, "http://barnew/x/y/z/boofar.html", "/x/y/z/boofar.html"},+ {"x/y/z/boofar.md", "x/y/z/", "http://barnew/", "boofar", true, "http://barnew/x/y/z/boofar.html", "/x/y/z/boofar.html"},}
for _, test := range tests {@@ -25,9 +31,14 @@
p := &Page{ Node: Node{ UrlPath: UrlPath{Section: "z"},- Site: SiteInfo{BaseUrl: test.base},+ Site: SiteInfo{+ BaseUrl: test.base,
+ Config: &Config{+ UglyUrls: test.uglyurls,
+ },
+ },
},
- File: File{FileName: test.file, Dir: test.dir},+ File: File{FileName: test.file, Dir: test.dir, Extension: "html"},}
if test.slug != "" {--
⑨