diff options
author | Igor Drozdov <idrozdov@gitlab.com> | 2022-08-05 15:55:43 +0000 |
---|---|---|
committer | Igor Drozdov <idrozdov@gitlab.com> | 2022-08-05 15:55:43 +0000 |
commit | c50becdff9b3b2c6ac2d248d063fad42684bb825 (patch) | |
tree | 994f5713a6de9416b508b813c2ed4ac67931271e /client/gitlabnet.go | |
parent | fe170537724ba95c7a7b776e1f02f8c19bfaa377 (diff) | |
parent | 15e7e01ef05f9ef72c72a82217267837ca1beaa7 (diff) | |
download | gitlab-shell-c50becdff9b3b2c6ac2d248d063fad42684bb825.tar.gz |
Merge branch 'I-365101' into 'main'
Fixed extra slashes in API request paths generated for geo
See merge request gitlab-org/gitlab-shell!673
Diffstat (limited to 'client/gitlabnet.go')
-rw-r--r-- | client/gitlabnet.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/client/gitlabnet.go b/client/gitlabnet.go index c34f148..a4f59d8 100644 --- a/client/gitlabnet.go +++ b/client/gitlabnet.go @@ -85,6 +85,10 @@ func normalizePath(path string) string { return path } +func appendPath(host string, path string) string { + return strings.TrimSuffix(host, "/") + "/" + strings.TrimPrefix(path, "/") +} + func newRequest(ctx context.Context, method, host, path string, data interface{}) (*http.Request, error) { var jsonReader io.Reader if data != nil { @@ -96,7 +100,7 @@ func newRequest(ctx context.Context, method, host, path string, data interface{} jsonReader = bytes.NewReader(jsonData) } - request, err := http.NewRequestWithContext(ctx, method, host+path, jsonReader) + request, err := http.NewRequestWithContext(ctx, method, appendPath(host, path), jsonReader) if err != nil { return nil, err } |