mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
Fix handling of content files with "." in them
As in, more dots than just to separate the extension and any language indicator. Fixes #4559
This commit is contained in:
@@ -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{
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user