Skip to content

Commit

Permalink
Merge pull request #30 from megaport/fix/url-building
Browse files Browse the repository at this point in the history
fix: uses net/url to build the API path instead of joining two strings
  • Loading branch information
mega-alex authored Apr 30, 2024
2 parents 73fd0e5 + c014ea3 commit 8a39f7e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"net/url"

"github.com/megaport/megaportgo/mega_err"
"github.com/megaport/megaportgo/shared"
Expand Down Expand Up @@ -45,9 +46,12 @@ func (c *Config) MakeAPICall(verb string, endpoint string, body []byte) (*http.R
var request *http.Request
var reqErr error

url := c.Endpoint + endpoint
url, err := url.JoinPath(c.Endpoint, endpoint)
if err != nil {
return nil, fmt.Errorf("could not create API endpoint URL: %w", err)
}

c.Log.Debugln("Making call to: ", string(url))
c.Log.Debugln("Making call to: ", url)

if body == nil {
request, reqErr = http.NewRequest(verb, url, nil)
Expand Down

0 comments on commit 8a39f7e

Please sign in to comment.