Alternately, the ext is only used once, so you could do:

```coffeescript
ensureImageExtension = (url) ->
  if /(png|jpe?g|gif)/.test url.split(".").pop()
    url
  else
    "#{url}#.png"
```

and that would achieve the same end.