From 838986b38ae61cfe854b1bb5c14e0bc10e89b542 Mon Sep 17 00:00:00 2001 From: David Bouchare Date: Wed, 11 Sep 2019 11:42:39 +0200 Subject: [PATCH] Distinguish URI from plain URLs --- request.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/request.go b/request.go index 9b46784..5661957 100644 --- a/request.go +++ b/request.go @@ -33,8 +33,8 @@ type Response struct { // and it will give the proper request URI to be posted to. func (client *Client) uriForAPI(api string) (string, error) { var err error - // If api is an endpoint starting with v1, we construct the apiBase URL using the baseUrl to which we append "/api" and the actual value of api - if strings.Contains(api, "v1") { + // If api is a URI such as /v1/hosts/, /v2/dashboards... add credentials and return a properly formatted URL + if !strings.HasPrefix(api, "https://") || !strings.HasPrefix(api, "http://") { apiBase, err := url.Parse(client.baseUrl + "/api" + api) if err != nil { return "", err