filenamify
Convert a string to a valid safe filename
Last updated a year ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install filenamify 
SYNC missed versions from official npm registry.

filenamify Build Status

Convert a string to a valid safe filename

On Unix-like systems / is reserved and <>:"/\|?* on Windows.

Install

$ npm install filenamify

Usage

const filenamify = require('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])

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: boolean
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

License

MIT © Sindre Sorhus

Current Tags

  • 4.1.0                                ...           latest (a year ago)

10 Versions

  • 4.1.0                                ...           a year ago
  • 4.0.0                                ...           a year ago
  • 3.0.0                                ...           a year ago
  • 2.1.0                                ...           2 years ago
  • 2.0.0                                ...           3 years ago
  • 1.2.1                                ...           4 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 2,830
This Week 33,320
This Month 69,565
Last Day 10,430
Last Week 54,828
Last Month 229,593
Dependencies (3)
Dev Dependencies (3)
Dependents (165)

Copyright 2014 - 2016 © taobao.org |