🐛 Fixed double slashes in Path.Dir

This commit is contained in:
Maxim Lebedev 2024-01-22 13:08:39 +06:00
parent 733a3e4e8b
commit 1718bf6f7e
Signed by: toby3d
GPG Key ID: 1F14E25B7C119FC5
1 changed files with 5 additions and 1 deletions

View File

@ -24,7 +24,7 @@ func NewPath(path string) Path {
Language: LanguageUnd,
baseFileName: "",
contentBaseName: "",
dir: filepath.Dir(path) + "/",
dir: filepath.Dir(path),
ext: strings.TrimPrefix(filepath.Ext(path), "."),
filename: path,
logicalName: filepath.Base(path),
@ -34,6 +34,10 @@ func NewPath(path string) Path {
}
out.baseFileName = strings.TrimSuffix(out.logicalName, filepath.Ext(out.logicalName))
if out.dir[len(out.dir)-1] != '/' {
out.dir += string(filepath.Separator)
}
parts := strings.Split(out.baseFileName, ".")
out.Language = NewLanguage(parts[len(parts)-1])
out.translationBaseName = strings.Join(parts[:len(parts)-1], ".")