hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit 0483299bc06a742d40528e0d675e42e149910853
parent 27b62a546cd5c49df7424caeabe4af35ddd3bd90
Author: Cameron Moore <moorereason@gmail.com>
Date:   Fri, 21 Dec 2018 02:42:37 -0600

hugolib: Improve logic of output path trimming

Fixes #4666


Diffstat:
Mhugolib/page_paths.go | 2+-
Mhugolib/page_permalink_test.go | 2++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/hugolib/page_paths.go b/hugolib/page_paths.go
@@ -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())
 	}
 
diff --git a/hugolib/page_permalink_test.go b/hugolib/page_permalink_test.go
@@ -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/"},