sindresorhus / filenamify

Convert a string to a valid safe filename
MIT License
489 stars 26 forks source link

Unicode normalization breaks filenames #40

Open falk0pr0ss opened 5 months ago

falk0pr0ss commented 5 months ago

Unfortunately the call of string.normalize('NFD') introduced in commit 4a0d964 and v5.1.0 breaks filenames including special characters like "äöü". The output strings can not be compared to the initial string values afterwards, which causes problems e.g. finding the files programatically.

Example:

"ä".normalize("NFD") === "ä" // false
"ä".normalize("NFC") === "ä" // true

Possible solution: Maybe the normalize parameter should be changed to "NFC" or blank (which defaults to NFC).