[MM-29224] Fix bug where markdown image link doesn't show preview (#15862)
* Fix bug where markdown image has no preview * go fmt * Fix failing test Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
@@ -316,6 +316,10 @@ func getFirstLinkAndImages(str string) (string, []string) {
|
|||||||
if firstLink == "" {
|
if firstLink == "" {
|
||||||
firstLink = v.Destination()
|
firstLink = v.Destination()
|
||||||
}
|
}
|
||||||
|
case *markdown.InlineLink:
|
||||||
|
if firstLink == "" {
|
||||||
|
firstLink = v.Destination()
|
||||||
|
}
|
||||||
case *markdown.InlineImage:
|
case *markdown.InlineImage:
|
||||||
images = append(images, v.Destination())
|
images = append(images, v.Destination())
|
||||||
case *markdown.ReferenceImage:
|
case *markdown.ReferenceImage:
|
||||||
|
|||||||
@@ -1280,11 +1280,11 @@ func TestGetFirstLinkAndImages(t *testing.T) {
|
|||||||
ExpectedFirstLink: "https://example.com",
|
ExpectedFirstLink: "https://example.com",
|
||||||
ExpectedImages: []string{"https://example.com/logo"},
|
ExpectedImages: []string{"https://example.com/logo"},
|
||||||
},
|
},
|
||||||
"markdown links (not returned)": {
|
"markdown links": {
|
||||||
Input: `this is a [our page](http://example.com) and [another page][]
|
Input: `this is a [our page](http://example.com) and [another page][]
|
||||||
|
|
||||||
[another page]: http://www.exaple.com/another_page`,
|
[another page]: http://www.exaple.com/another_page`,
|
||||||
ExpectedFirstLink: "",
|
ExpectedFirstLink: "http://example.com",
|
||||||
ExpectedImages: []string{},
|
ExpectedImages: []string{},
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user