hugolib: Improve logic of output path trimming
authorCameron Moore <moorereason@gmail.com>
Fri, 21 Dec 2018 08:42:37 +0000 (02:42 -0600)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 21 Dec 2018 08:42:37 +0000 (09:42 +0100)
Fixes #4666

hugolib/page_paths.go
hugolib/page_permalink_test.go

index 756a0f2f2d638ddd1bc722045d1b33916601bc9f..a24789bf9418f30c2607e7b3277fbb4ec12ec20e 100644 (file)
@@ -310,7 +310,7 @@ func (p *Page) createRelativeTargetPathForOutputFormat(f output.Format) string {
        }
 
        // For /index.json etc. we must  use the full path.
-       if strings.HasSuffix(f.BaseFilename(), "html") {
+       if f.MediaType.FullSuffix() == ".html" && filepath.Base(tp) == "index.html" {
                tp = strings.TrimSuffix(tp, f.BaseFilename())
        }
 
index 6f899efaeacede2132a117f9d117df43c4484d69..76b0b86354d58653de20e7e28a762f7823c283f5 100644 (file)
@@ -55,6 +55,8 @@ func TestPermalink(t *testing.T) {
                {"x/y/z/boofar.md", "http://barnew/boo/", "booslug", "", false, false, "http://barnew/boo/x/y/z/booslug/", "/boo/x/y/z/booslug/"},
                {"x/y/z/boofar.md", "http://barnew/boo/", "booslug", "", true, true, "http://barnew/boo/x/y/z/booslug.html", "/x/y/z/booslug.html"},
                {"x/y/z/boofar.md", "http://barnew/boo", "booslug", "", true, true, "http://barnew/boo/x/y/z/booslug.html", "/x/y/z/booslug.html"},
+               // Issue #4666
+               {"x/y/z/boo-makeindex.md", "http://barnew/boo", "", "", true, true, "http://barnew/boo/x/y/z/boo-makeindex.html", "/x/y/z/boo-makeindex.html"},
 
                // test URL overrides
                {"x/y/z/boofar.md", "", "", "/z/y/q/", false, false, "/z/y/q/", "/z/y/q/"},