Bugfix/trailing path separator (#1683)

* Test_EnvReplacement: env of path ends in a slash

* Fix trailing path separator
This commit is contained in:
nihilo
2021-07-08 12:06:52 -07:00
committed by GitHub
parent 1d9bc175c2
commit 682191f523
2 changed files with 11 additions and 2 deletions
+3 -2
View File
@@ -79,9 +79,10 @@ func ResolveEnvironmentReplacement(value string, envs []string, isFilepath bool)
if err != nil {
return "", err
}
isDir := strings.HasSuffix(fp, pathSeparator)
fp = filepath.Clean(fp)
if IsDestDir(value) && !IsDestDir(fp) {
fp = fp + "/"
if isDir && !strings.HasSuffix(fp, pathSeparator) {
fp = fp + pathSeparator
}
return fp, nil
}
+8
View File
@@ -53,6 +53,14 @@ var testEnvReplacement = []struct {
isFilepath: true,
expectedPath: "/simple/path/",
},
{
path: "$simple",
envs: []string{
"simple=/path/",
},
isFilepath: true,
expectedPath: "/path/",
},
{
path: "${a}/b",
envs: []string{