sanitize-basename
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

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

Package Sidebar

Install

npm i sanitize-basename

Weekly Downloads

298

Version

2.0.1

License

none

Unpacked Size

9.09 kB

Total Files

17

Last publish

Collaborators

  • fabiospampinato