From a6f50e675cbee8766e847c21230eca6c66fd13a7 Mon Sep 17 00:00:00 2001 From: Irena Rindos Date: Wed, 16 Feb 2022 10:15:02 -0500 Subject: [PATCH] fix(api): address base paths containing a v1 were being truncated --- api/client.go | 2 +- api/client_test.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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 {