Skip to content

Commit

Permalink
Bugfix/trailing path separator (#1683)
Browse files Browse the repository at this point in the history
* Test_EnvReplacement: env of path ends in a slash

* Fix trailing path separator
  • Loading branch information
nihilox authored Jul 8, 2021
1 parent 1d9bc17 commit 682191f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/util/command_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/util/command_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 682191f

Please sign in to comment.