From 2817e842407c8dcbfc738297ab634392fcb41ce1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sat, 7 Apr 2018 10:10:06 +0200 Subject: Fix handling of content files with "." in them As in, more dots than just to separate the extension and any language indicator. Fixes #4559 --- source/fileInfo.go | 5 ++--- source/fileInfo_test.go | 7 +++++++ 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/fileInfo.go b/source/fileInfo.go index 882ef22a7..412d64050 100644 --- a/source/fileInfo.go +++ b/source/fileInfo.go @@ -204,9 +204,8 @@ func (sp *SourceSpec) NewFileInfo(baseDir, filename string, isLeafBundle bool, f // This is usyally provided by the filesystem. But this FileInfo is also // created in a standalone context when doing "hugo new". This is // an approximate implementation, which is "good enough" in that case. - translationBaseName = strings.TrimSuffix(baseName, ext) - fileLangExt := filepath.Ext(translationBaseName) - translationBaseName = strings.TrimSuffix(translationBaseName, fileLangExt) + fileLangExt := filepath.Ext(baseName) + translationBaseName = strings.TrimSuffix(baseName, fileLangExt) } f := &FileInfo{ diff --git a/source/fileInfo_test.go b/source/fileInfo_test.go index 770478e60..ec2a17c65 100644 --- a/source/fileInfo_test.go +++ b/source/fileInfo_test.go @@ -49,6 +49,13 @@ func TestFileInfo(t *testing.T) { assert.Equal("b", f.Section()) }}, + {filepath.FromSlash("/a/"), filepath.FromSlash("/a/b/page.en.MD"), func(f *FileInfo) { + assert.Equal("b", f.Section()) + assert.Equal(filepath.FromSlash("b/page.en.MD"), f.Path()) + assert.Equal(filepath.FromSlash("page"), f.TranslationBaseName()) + assert.Equal(filepath.FromSlash("page.en"), f.BaseFileName()) + + }}, } { f := s.NewFileInfo(this.base, this.filename, false, nil) this.assert(f) -- cgit v1.2.3