2.0.1 • Published 1 month ago

sanitize-basename v2.0.1

Weekly downloads
4
License
-
Repository
github
Last release
1 month ago

Sanitize Basename

Sanitize a file name for cross-platform validity.

Instead of stripping out forbidden characters, like other libraries do, this library tries to replace them with similar-looking characters, trying to mainting maximum fidelity while still outputting valid file names for all platforms.

Install

npm install --save sanitize-basename

Usage

import sanitize from 'sanitize-basename';

sanitize ( '../foo' ); // => 'foo'
sanitize ( '<>:"/\\|?*.txt' ); // => '‹›꞉ˮ⁄∖ǀʔ⁎.txt'
sanitize ( 'aaaaaaaaaaaaaaaaa.txt', { maxLength: 10 } ); // => aaaaaa.txt

Related

License

MIT © Fabio Spampinato