PLT-5379 Fix the error occuring while fetching OG metadata for links which don't exist. (#5308)

Этот коммит содержится в:
Debanshu Kundu
2017-02-07 20:56:14 +05:30
коммит произвёл enahum
родитель 439d5b7ed7
Коммит 5cc30fa061
2 изменённых файлов: 2 добавлений и 1 удалений

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

@@ -444,6 +444,7 @@ func getOpenGraphMetadata(c *Context, w http.ResponseWriter, r *http.Request) {
ogJson, err := og.ToJSON()
if err != nil {
w.Write([]byte(`{"url": ""}`))
return
}
w.Write(ogJson)
}

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

@@ -488,10 +488,10 @@ func GetOpenGraphMetadata(url string) *opengraph.OpenGraph {
og := opengraph.NewOpenGraph()
res, err := http.Get(url)
defer CloseBody(res)
if err != nil {
return og
}
defer CloseBody(res)
if err := og.ProcessHTML(res.Body); err != nil {
return og