yihui / xfun

Miscellaneous R functions
https://yihui.org/xfun/
Other
135 stars 28 forks source link

Known file extensions #68

Closed tentacles-from-outer-space closed 2 years ago

tentacles-from-outer-space commented 2 years ago

Recently I noticed that file_ext only detects alphanumeric extensions (or ending in ~ or #). I looked at https://en.wikipedia.org/wiki/List_of_filename_extensions and there are ones with special chars:

c-- c++ e## FB2K-COMPONENT H! H-- H++ SEARCH-MS VBOX-EXTPACK WITNESS_CAMPAIGN

So question is: Should special characters in extensions be allowed? (at least - and _)

yihui commented 2 years ago

Done. Thanks for the suggestion!

yihui commented 2 years ago

Sorry I have to revert this change because it caused a breakage in https://github.com/rstudio/bookdown/issues/1369. Now you'd have to explicitly provide the extra characters to be allowed in filename extensions, e.g.,

xfun::file_ext(x, extra = '-+!_#')