diff --git a/middleware.go b/middleware.go index d94b8a1..64573d0 100644 --- a/middleware.go +++ b/middleware.go @@ -57,7 +57,7 @@ func parseRequestURL(c *Client, r *Request) error { buf := acquireBuffer() defer releaseBuffer(buf) // search for the next or first opened curly bracket - for curr := strings.Index(r.URL, "{"); curr == 0 || curr > prev; curr = prev + strings.Index(r.URL[prev:], "{") { + for curr := strings.Index(r.URL, "{"); curr == 0 || curr >= prev; curr = prev + strings.Index(r.URL[prev:], "{") { // write everything from the previous position up to the current if curr > prev { buf.WriteString(r.URL[prev:curr]) diff --git a/request_test.go b/request_test.go index c4809ed..00127d3 100644 --- a/request_test.go +++ b/request_test.go @@ -1827,10 +1827,11 @@ func TestGetPathParamAndPathParams(t *testing.T) { c := dc(). SetBaseURL(ts.URL). - SetPathParam("userId", "sample@sample.com") + SetPathParam("userId", "sample@sample.com"). + SetRawPathParam("details", "/details") resp, err := c.R().SetPathParam("subAccountId", "100002"). - Get("/v1/users/{userId}/{subAccountId}/details") + Get("/v1/users/{userId}/{subAccountId}{details}") assertError(t, err) assertEqual(t, http.StatusOK, resp.StatusCode())