Enhance Portainer URL parsing in Client

This commit is contained in:
Juan Carlos Mejías Rodríguez 2019-08-02 16:09:54 -04:00
parent 00439cc1c1
commit 0d42ed73c6

View File

@ -10,6 +10,7 @@ import (
"io/ioutil"
"net/http"
"net/url"
"strings"
"time"
"github.com/spf13/viper"
@ -282,7 +283,7 @@ func (n *PortainerClient) Clone() (c *PortainerClient, err error) {
// Create a new client
func NewClient(config ClientConfig) (c *PortainerClient, err error) {
apiUrl, err := url.Parse(config.Url + "/api/")
apiUrl, err := url.Parse(strings.TrimRight(config.Url, "/") + "/api/")
if err != nil {
return
}