1
0
mirror of https://github.com/velour/catbase.git synced 2025-04-04 04:01:42 +00:00

meme: handle bad URL errors

This commit is contained in:
Chris Sexton 2020-06-10 15:35:16 -04:00
parent 12ca34006f
commit 828c19d7eb

View File

@ -114,7 +114,12 @@ func (p *MemePlugin) all(w http.ResponseWriter, r *http.Request) {
realURL, err := url.Parse(u)
if err != nil || realURL.Scheme == "" {
realURL, _ = url.Parse("https://imgflip.com/s/meme/" + u)
realURL, err = url.Parse("https://imgflip.com/s/meme/" + u)
if err != nil {
values = append(values, webResp{n, "404.png"})
log.Error().Err(err).Msgf("invalid URL")
continue
}
}
values = append(values, webResp{n, realURL.String()})
}