|
|
hai 1 mes | |
|---|---|---|
| .. | ||
| filenamify-path.d.ts | hai 1 mes | |
| filenamify-path.js | hai 1 mes | |
| filenamify.d.ts | hai 1 mes | |
| filenamify.js | hai 1 mes | |
| index.d.ts | hai 1 mes | |
| index.js | hai 1 mes | |
| license | hai 1 mes | |
| package.json | hai 1 mes | |
| readme.md | hai 1 mes | |
Convert a string to a valid safe filename
On Unix-like systems, / is reserved. On Windows, <>:"/\|?* along with trailing periods are reserved.
$ npm install filenamify
const filenamify = require('filenamify');
filenamify('<foo/bar>');
//=> 'foo!bar'
filenamify('foo:"bar"', {replacement: '🐴'});
//=> 'foo🐴bar'
Convert a string to a valid filename.
Convert the filename in a path a valid filename and return the augmented path.
Type: object
Type: string\
Default: '!'
String to use as replacement for reserved filename characters.
Cannot contain: < > : " / \ | ? *
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.
You can also import filenamify/browser, which only imports filenamify and not filenamify.path, which relies on path being available or polyfilled. Importing filenamify this way is therefore useful when it is shipped using webpack or similar tools, and if filenamify.path is not needed.
const filenamify = require('filenamify/browser');
filenamify('<foo/bar>');
//=> 'foo!bar'