Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Allow URLs without protocol. (#238)
Browse files Browse the repository at this point in the history
* Allow URLs without protocol.
  • Loading branch information
ihorhorobets-bolt authored Jul 5, 2022
1 parent ebed76a commit c37d902
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion gateways/cardconnect/cardconnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io/ioutil"
"net/http"
"net/url"
"strings"

"github.com/BoltApp/sleet"
"github.com/BoltApp/sleet/common"
Expand All @@ -22,7 +23,7 @@ func NewWithHttpClient(username string, password string, merchantID string, URL
username: username,
password: password,
merchantID: merchantID,
URL: URL,
URL: normalizeURL(URL),
}
}

Expand All @@ -38,6 +39,14 @@ func (client *CardConnectClient) buildURL(path string) (string, error) {
return url.String(), nil
}

func normalizeURL(URL string) string {
if strings.HasPrefix(URL, "http://") || strings.HasPrefix(URL, "https://") {
return URL
}

return "https://" + URL
}

func (client *CardConnectClient) sendRequest(request *Request, path string) (*Response, *http.Response, error) {
request.MerchantID = client.merchantID

Expand Down

0 comments on commit c37d902

Please sign in to comment.