diff --git a/pkg/util/command_util.go b/pkg/util/command_util.go index 6d9471ebd..15ed41b18 100644 --- a/pkg/util/command_util.go +++ b/pkg/util/command_util.go @@ -65,7 +65,8 @@ func ResolveEnvironmentReplacementList(values, envs []string, isFilepath bool) ( func ResolveEnvironmentReplacement(value string, envs []string, isFilepath bool) (string, error) { shlex := shell.NewLex(parser.DefaultEscapeToken) fp, err := shlex.ProcessWord(value, envs) - if !isFilepath { + // Check after replacement if value is a remote URL + if !isFilepath || IsSrcRemoteFileURL(fp) { return fp, err } if err != nil { diff --git a/pkg/util/command_util_test.go b/pkg/util/command_util_test.go index 3e2342595..6f7aa01a7 100644 --- a/pkg/util/command_util_test.go +++ b/pkg/util/command_util_test.go @@ -97,6 +97,14 @@ var testEnvReplacement = []struct { }, expectedPath: "8080/udp", }, + { + path: "$url", + envs: []string{ + "url=http://example.com", + }, + isFilepath: true, + expectedPath: "http://example.com", + }, } func Test_EnvReplacement(t *testing.T) { @@ -472,15 +480,16 @@ func TestResolveEnvironmentReplacementList(t *testing.T) { name: "url", args: args{ values: []string{ - "https://google.com/$foo", "$bar", + "https://google.com/$foo", "$bar", "$url", }, envs: []string{ "foo=baz", "bar=bat", + "url=https://google.com", }, }, - want: []string{"https://google.com/baz", "bat"}, - }, + want: []string{"https://google.com/baz", "bat", "https://google.com"}, + }, { name: "mixed", args: args{