processwire / processwire-requests

ProcessWire feature requests.
40 stars 0 forks source link

Make cleanBasename() use dashes instead of underscores #385

Open adrianbj opened 3 years ago

adrianbj commented 3 years ago

Short description of the enhancement

I have come to really dislike underscores in urls and filenames and I'm certainly not the only one: https://x-equals.com/dashes-versus-underscores/

But beyond the personal preference and the sound arguments provided in that post, it also looks really weird to me when opening up a path to a PDF or image, especially when there is a -n if required to make the filename unique. The mixing of underscores and dashes is jarring and is not consistent with the page names / slugs that PW uses.

https://mysite.com/site/assets/files/1001/my_big_report-1.pdf

adrianbj commented 3 years ago

Also, just noticed that cleanBasename() results in duplicate underscores when there are certain character present in the filename, eg:

image

adrianbj commented 3 years ago

It gets even weirder when you set the $translate option to true. Now, that : ends up as a dash which adds to the dash vs underscore mess :)

image

adrianbj commented 3 years ago

Just another example of inconsistencies in filenames is the DatabaseBackups module. If we don't specify a name, it uses a dash, but if we do and leave spaces, these are replaced by underscores.

image