Skip to content

Commit 0424ad1

Browse files
authored
fix: correct url path params processing order #519 (#705)
1 parent 3b6258d commit 0424ad1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

middleware.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,25 @@ const debugRequestLogKey = "__restyDebugRequestLog"
2727

2828
func parseRequestURL(c *Client, r *Request) error {
2929
// GitHub #103 Path Params
30-
if len(r.PathParams) > 0 {
31-
for p, v := range r.PathParams {
30+
if len(c.PathParams) > 0 {
31+
for p, v := range c.PathParams {
3232
r.URL = strings.Replace(r.URL, "{"+p+"}", url.PathEscape(v), -1)
3333
}
3434
}
35-
if len(c.PathParams) > 0 {
36-
for p, v := range c.PathParams {
35+
if len(r.PathParams) > 0 {
36+
for p, v := range r.PathParams {
3737
r.URL = strings.Replace(r.URL, "{"+p+"}", url.PathEscape(v), -1)
3838
}
3939
}
4040

4141
// GitHub #663 Raw Path Params
42-
if len(r.RawPathParams) > 0 {
43-
for p, v := range r.RawPathParams {
42+
if len(c.RawPathParams) > 0 {
43+
for p, v := range c.RawPathParams {
4444
r.URL = strings.Replace(r.URL, "{"+p+"}", v, -1)
4545
}
4646
}
47-
if len(c.RawPathParams) > 0 {
48-
for p, v := range c.RawPathParams {
47+
if len(r.RawPathParams) > 0 {
48+
for p, v := range r.RawPathParams {
4949
r.URL = strings.Replace(r.URL, "{"+p+"}", v, -1)
5050
}
5151
}

0 commit comments

Comments
 (0)