Merge pull request #1862 from hashicorp/irindos-api-client-path

fix(api): address base paths containing a v1 were being truncated
pull/1864/head
Irena Rindos 4 years ago committed by GitHub
commit be569dee78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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]
}

@ -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 {

Loading…
Cancel
Save