meme: handle bad URL errors

This commit is contained in:
Chris Sexton 2020-06-10 15:35:16 -04:00 committed by Chris Sexton
parent 12ca34006f
commit 45adb3a242
1 changed files with 6 additions and 1 deletions

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()})
}