source: Make sure .File.Dir() ends with a slash

Updates #4190
This commit is contained in:
Bjørn Erik Pedersen
2017-12-28 11:32:02 +01:00
parent 3cdf19e9b7
commit 1b0780dbeb
5 changed files with 35 additions and 15 deletions

View File

@@ -1940,18 +1940,11 @@ func (p *Page) addLangPathPrefixIfFlagSet(outfile string, should bool) string {
}
func sectionsFromDir(dirname string) []string {
sections := strings.Split(dirname, helpers.FilePathSeparator)
if len(sections) == 1 {
if sections[0] == "" {
return nil
}
return sections
dirname = strings.Trim(dirname, helpers.FilePathSeparator)
if dirname == "" {
return nil
}
if len(sections) > 1 && sections[0] == "" {
return sections[1:]
}
return sections
return strings.Split(dirname, helpers.FilePathSeparator)
}
const (