diff --git a/api/cloudcontroller/ccv3/query.go b/api/cloudcontroller/ccv3/query.go index aed50ae0f2d..d5280cc4497 100644 --- a/api/cloudcontroller/ccv3/query.go +++ b/api/cloudcontroller/ccv3/query.go @@ -119,7 +119,8 @@ func FormatQueryParameters(queries []Query) url.Values { if query.Key == NameFilter { encodedParamValues := []string{} for _, valString := range query.Values { - encodedParamValues = append(encodedParamValues, url.QueryEscape(valString)) + commaEncoded := strings.ReplaceAll(valString, ",", "%2C") + encodedParamValues = append(encodedParamValues, commaEncoded) } query.Values = encodedParamValues } diff --git a/api/cloudcontroller/ccv3/query_test.go b/api/cloudcontroller/ccv3/query_test.go index 01d75328246..35e1928bffa 100644 --- a/api/cloudcontroller/ccv3/query_test.go +++ b/api/cloudcontroller/ccv3/query_test.go @@ -36,15 +36,15 @@ var _ = Describe("Query Helpers", func() { inputQueries = []Query{ { Key: NameFilter, - Values: []string{"name1", "name,2"}, + Values: []string{"name1", "name,2", "name 3"}, }, } outputParameters = FormatQueryParameters(inputQueries) }) - It("encodes the param values before formatting", func() { + It("encodes commas before formatting", func() { Expect(outputParameters).To(Equal(url.Values{ - "names": []string{"name1,name%2C2"}, + "names": []string{"name1,name%2C2,name 3"}, })) }) })