diff --git a/cmd/config.go b/cmd/config.go index 89af9536..e3c43e2a 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -231,7 +231,7 @@ func parseEnvURLStr(envURL string) (*url.URL, string, string, *probe.Error) { res := re.FindAllStringSubmatch(envURL, -1) // regex will return full match, scheme, accessKey, secretKey and endpoint:port as // captured groups. - if len(res[0]) != 5 { + if res == nil || len(res[0]) != 5 { return nil, "", "", err } for k, v := range res[0] { diff --git a/cmd/config_test.go b/cmd/config_test.go index 6f8859cd..4aa2a3f3 100644 --- a/cmd/config_test.go +++ b/cmd/config_test.go @@ -69,3 +69,10 @@ func TestParseEnvURLStr(t *testing.T) { } } } + +func TestParseEnvURLStrInvalid(t *testing.T) { + _, _, _, err := parseEnvURLStr("") + if err == nil { + t.Fatalf("Expected failure") + } +}