cleaned up code generating filenames from urls. In particular do something sensible if the url ends with a slash.