fix: double slash on api requests when no urlbase is defined

Signed-off-by: Devin Buhl <devin@buhl.casa>
This commit is contained in:
Devin Buhl 2021-12-03 09:49:11 -05:00
parent c25265681a
commit a2a66246bd
No known key found for this signature in database
GPG Key ID: 97F4936F1BCD7E35

View File

@ -46,7 +46,7 @@ func (c *Client) DoRequest(endpoint string, target interface{}) error {
// Use the values from config.xml if using the config flag
if c.config.String("config") != "" {
url = fmt.Sprintf("%s:%s/%s/api/%s/%s",
url = fmt.Sprintf("%s:%s%s/api/%s/%s",
c.config.String("url"),
c.configFile.Port,
c.configFile.UrlBase,
@ -90,6 +90,7 @@ func (c *Client) DoRequest(endpoint string, target interface{}) error {
log.Fatal(errMsg)
return errors.New(errMsg)
}
defer resp.Body.Close()
return json.NewDecoder(resp.Body).Decode(target)
}