4.1.0 • Published 4 years ago
react-native-filenamify v4.1.0
react-native-filenamify
Convert a string to a valid safe filename
On Unix-like systems /
is reserved and <>:"/\|?*
on Windows.
Install
$ npm install react-native-filenamify
Usage
const filenamify = require('react-native-filenamify');
filenamify('<foo/bar>');
//=> 'foo!bar'
filenamify('foo:"bar"', {replacement: '🐴'});
//=> 'foo🐴bar'
API
filenamify(string, options)
Convert a string to a valid filename.
filenamify.path(path, options) (removed due to incompatibility with react-native)
Convert the filename in a path a valid filename and return the augmented path.
options
Type: Object
replacement
Type: string
Default: '!'
String to use as replacement for reserved filename characters.
Cannot contain: <
>
:
"
/
\
|
?
*
maxLength
Type: number
Default: 100
Truncate the filename to the given length.
Systems generally allow up to 255 characters, but we default to 100 for usability reasons.
Related
- filenamify-cli - CLI for this module
- filenamify-url - Convert a URL to a valid filename
- valid-filename - Check if a string is a valid filename
- unused-filename - Get a unused filename by appending a number if it exists
- slugify - Slugify a string
License
MIT © Sindre Sorhus
4.1.0
4 years ago