Trimmed trailing slash in URL provided to create Client API (#15513)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ee76ad435b
Коммит
e726b04268
@@ -116,6 +116,7 @@ func (c *Client4) Must(result interface{}, resp *Response) interface{} {
|
||||
}
|
||||
|
||||
func NewAPIv4Client(url string) *Client4 {
|
||||
url = strings.TrimRight(url, "/")
|
||||
return &Client4{url, url + API_URL_SUFFIX, &http.Client{}, "", "", map[string]string{}, "", ""}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,19 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// https://github.com/mattermost/mattermost-plugin-starter-template/issues/115
|
||||
func TestClient4TrimTrailingSlash(t *testing.T) {
|
||||
slashes := []int{0, 1, 5}
|
||||
baseUrl := "https://foo.com:1234"
|
||||
|
||||
for _, s := range slashes {
|
||||
testUrl := baseUrl + strings.Repeat("/", s)
|
||||
client := NewAPIv4Client(testUrl)
|
||||
assert.Equal(t, baseUrl, client.Url)
|
||||
assert.Equal(t, baseUrl+API_URL_SUFFIX, client.ApiUrl)
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/mattermost/mattermost-server/v5/issues/8205
|
||||
func TestClient4CreatePost(t *testing.T) {
|
||||
post := &Post{
|
||||
|
||||
Ссылка в новой задаче
Block a user