diff --git a/api/client.go b/api/client.go index c71de9fefa..cbaba407c3 100644 --- a/api/client.go +++ b/api/client.go @@ -236,7 +236,7 @@ func (c *Config) setAddr(addr string) error { // If there is a v1 segment, elide everything after it. Do this only for // the last v1 segment in case it's part of the base path. - if lastIndex := strings.LastIndex(u.Path, "v1"); lastIndex != -1 { + if lastIndex := strings.LastIndex(u.Path, "v1/"); lastIndex != -1 { u.Path = u.Path[:lastIndex] } diff --git a/api/client_test.go b/api/client_test.go index 9688e7afff..fa8adf279d 100644 --- a/api/client_test.go +++ b/api/client_test.go @@ -57,6 +57,12 @@ func TestConfigSetAddress(t *testing.T) { "http://127.0.0.1:9200/my-install", "", }, + { + "valid project path containing v1", + "http://127.0.0.1:9200/randomPathHasv1InIt", + "http://127.0.0.1:9200/randomPathHasv1InIt", + "", + }, } for _, v := range tests {