Close
url = url.replace(/(.*\/image\/)([0-9a-f]{32})\/.*(\.[^. ]+)/, "$1$2$3")

(A lot easier than the script I've been using to get sensible filenames for the last few months, which involved rewriting URLs to a PHP script on another machine, which set Content-Disposition headers and proxied the file...)