What the code was trying to do was helpfully add a directory and extension if none were specified, but it did this by checking whether the filename was composed of a very limited character set that didn't even include dashes. With this change, the intention of the code is clearer, and I can put dashes in my screenshot names.