[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>
Этот коммит содержится в:
camgraff
2020-10-14 07:36:46 -05:00
коммит произвёл GitHub
родитель fa9279a675
Коммит 07948ae7bc
2 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@@ -316,6 +316,10 @@ func getFirstLinkAndImages(str string) (string, []string) {
if firstLink == "" {
firstLink = v.Destination()
}
case *markdown.InlineLink:
if firstLink == "" {
firstLink = v.Destination()
}
case *markdown.InlineImage:
images = append(images, v.Destination())
case *markdown.ReferenceImage:

Просмотреть файл

@@ -1280,11 +1280,11 @@ func TestGetFirstLinkAndImages(t *testing.T) {
ExpectedFirstLink: "https://example.com",
ExpectedImages: []string{"https://example.com/logo"},
},
"markdown links (not returned)": {
"markdown links": {
Input: `this is a [our page](http://example.com) and [another page][]
[another page]: http://www.exaple.com/another_page`,
ExpectedFirstLink: "",
ExpectedFirstLink: "http://example.com",
ExpectedImages: []string{},
},
} {