I think a couple of lines extra for better readability here is worth it.
It's a bit obfuscated that we are looking for an extension with the split
and pop. Liked your first suggestion.
On Jun 3, 2014 8:19 PM, "Parker Moore" <notifications@github.com> wrote:

> In src/scripts/google-images.coffee:
>
> > @@ -39,6 +39,14 @@ imageMe = (msg, query, animated, faces, cb) ->
> >        images = JSON.parse(body)
> >        images = images.responseData?.results
> >        if images?.length > 0
> > -        image  = msg.random images
> > -        cb "#{image.unescapedUrl}#.png"
> > +        image = msg.random images
> > +        cb ensureImageExtension image.unescapedUrl
> > +
> > +ensureImageExtension = (url) ->
> > +  ext = url.split('.').pop()
> > +
> > +  if ['png', 'jpeg', 'jpg', 'gif'].indexOf(ext) != -1
> > +    return url
> > +
> > +  return "#{url}#.png"
>
> Alternately, the ext is only used once, so you could do:
>
> ensureImageExtension = (url) ->
>   if /(png|jpe?g|gif)/.test url.split(".").pop()
>     url
>   else
>     "#{url}#.png"
>
> and that would achieve the same end.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/github/hubot/pull/708/files#r13350218>.
>