mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-24 13:56:04 +03:00
trim base URL in the constructor
This commit is contained in:
parent
cd567755e7
commit
31ede381e4
@ -20,7 +20,7 @@ import (
|
||||
// New initialize client.
|
||||
func New(url string, key string) *Client {
|
||||
return &Client{
|
||||
URL: url,
|
||||
URL: strings.TrimRight(url, "/"),
|
||||
Key: key,
|
||||
httpClient: &http.Client{Timeout: time.Minute},
|
||||
}
|
||||
|
@ -68,6 +68,15 @@ func badurlclient() *Client {
|
||||
return New(badURL, os.Getenv("RETAILCRM_KEY"))
|
||||
}
|
||||
|
||||
func TestBaseURLTrimmed(t *testing.T) {
|
||||
c1 := New("https://test.retailcrm.pro", "key")
|
||||
c2 := New("https://test.retailcrm.pro/", "key")
|
||||
c3 := New("https://test.retailcrm.pro////", "key")
|
||||
|
||||
assert.Equal(t, c1.URL, c2.URL)
|
||||
assert.Equal(t, c1.URL, c3.URL)
|
||||
}
|
||||
|
||||
func TestGetRequest(t *testing.T) {
|
||||
c := client()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user