From abeb9655f9773c09cfc54501af75f108f817502c Mon Sep 17 00:00:00 2001 From: Jakob Schrettenbrunner Date: Sun, 10 Jan 2021 00:24:07 +0000 Subject: [PATCH] fix request paths --- panelapi/client.go | 5 +++-- panelapi/http.go | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/panelapi/client.go b/panelapi/client.go index 90eab83..615950a 100644 --- a/panelapi/client.go +++ b/panelapi/client.go @@ -3,7 +3,7 @@ package panelapi import ( "context" "net/http" - "path/filepath" + "strings" "time" "github.com/pterodactyl/wings/api" @@ -35,8 +35,9 @@ func CreateClient(base, tokenId, token string, opts ...ClientOption) Client { httpClient := &http.Client{ Timeout: time.Second * 15, } + base = strings.TrimSuffix(base, "/") c := &client{ - baseUrl: filepath.Join(base, "api/remote"), + baseUrl: base + "/api/remote", tokenId: tokenId, token: token, httpClient: httpClient, diff --git a/panelapi/http.go b/panelapi/http.go index 96bc587..509a11a 100644 --- a/panelapi/http.go +++ b/panelapi/http.go @@ -9,7 +9,6 @@ import ( "io" "io/ioutil" "net/http" - "path/filepath" "github.com/pterodactyl/wings/system" ) @@ -35,7 +34,7 @@ type q map[string]string // Prefer request() over this method when possible. // It appends the path to the endpoint of the client and adds the authentication token to the request. func (c *client) requestOnce(ctx context.Context, method, path string, body io.Reader, opts ...func(r *http.Request)) (*Response, error) { - req, err := http.NewRequest(method, filepath.Join(c.baseUrl, path), body) + req, err := http.NewRequest(method, c.baseUrl+path, body) if err != nil { return nil, err }