Skip to content

Commit 7f3fb10

Browse files
authored
Do not prepend paths starting with ~ or variable reference (#1905)
## Changes Fixes #1904 ## Tests Added regression test
1 parent 1db3840 commit 7f3fb10

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

bundle/config/mutator/prepend_workspace_prefix.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ func (m *prependWorkspacePrefix) Apply(ctx context.Context, b *bundle.Bundle) di
4444
return dyn.InvalidValue, fmt.Errorf("expected string, got %s", v.Kind())
4545
}
4646

47+
// Skip prefixing if the path does not start with /, it might be variable reference or smth else.
48+
if !strings.HasPrefix(path, "/") {
49+
return pv, nil
50+
}
51+
4752
for _, prefix := range skipPrefixes {
4853
if strings.HasPrefix(path, prefix) {
4954
return pv, nil

bundle/config/mutator/prepend_workspace_prefix_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ func TestPrependWorkspacePrefix(t *testing.T) {
3131
path: "/Volumes/Users/test",
3232
expected: "/Volumes/Users/test",
3333
},
34+
{
35+
path: "~/test",
36+
expected: "~/test",
37+
},
38+
{
39+
path: "${workspace.file_path}/test",
40+
expected: "${workspace.file_path}/test",
41+
},
3442
}
3543

3644
for _, tc := range testCases {

0 commit comments

Comments
 (0)