[MM-63455] Fix Link previews with brackets when making the request (#30507)
* allow opening angle bracket before links * cut off link before an angle bracket(both open & close) * add more test cases for ParseURLAutolink func * add more test cases for ParseWWWAutolink func * add more test cases for TrimTrailingCharactersFromLink func * add more test cases for GetFirstLinkAndImages func * add test cases for isAllowedBeforeWWWLink func * allow closing angle bracket and opening paranthesis before links --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
fb301d8b0a
Коммит
62753a1481
@@ -1727,12 +1727,27 @@ func TestGetFirstLinkAndImages(t *testing.T) {
|
||||
ExpectedFirstLink: "",
|
||||
ExpectedImages: []string{},
|
||||
},
|
||||
"http link in angle brackets": {
|
||||
Input: "this is a <http://example.com>",
|
||||
ExpectedFirstLink: "http://example.com",
|
||||
ExpectedImages: []string{},
|
||||
},
|
||||
"http link with only opening angle bracket": {
|
||||
Input: "this is a <http://example.com",
|
||||
ExpectedFirstLink: "http://example.com",
|
||||
ExpectedImages: []string{},
|
||||
},
|
||||
"http link with only closing angle bracket": {
|
||||
Input: "this is a http://example.com>",
|
||||
ExpectedFirstLink: "http://example.com",
|
||||
ExpectedImages: []string{},
|
||||
},
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
firstLink, images := th.App.getFirstLinkAndImages(th.Context, testCase.Input)
|
||||
|
||||
assert.Equal(t, firstLink, testCase.ExpectedFirstLink)
|
||||
assert.Equal(t, images, testCase.ExpectedImages)
|
||||
assert.Equal(t, testCase.ExpectedFirstLink, firstLink)
|
||||
assert.Equal(t, testCase.ExpectedImages, images)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user