mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-21 20:36:03 +03:00
Trim base URL in the constructor
This commit is contained in:
commit
9c7c641217
@ -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