You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # filenamify [![Build Status](https://travis-ci.org/sindresorhus/filenamify.svg?branch=master)](https://travis-ci.org/sindresorhus/filenamify)
  2. > Convert a string to a valid safe filename
  3. On Unix-like systems `/` is reserved and [`<>:"/\|?*`](http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29#naming_conventions) on Windows.
  4. ## Install
  5. ```
  6. $ npm install filenamify
  7. ```
  8. ## Usage
  9. ```js
  10. const filenamify = require('filenamify');
  11. filenamify('<foo/bar>');
  12. //=> 'foo!bar'
  13. filenamify('foo:"bar"', {replacement: '🐴'});
  14. //=> 'foo🐴bar'
  15. ```
  16. ## API
  17. ### filenamify(input, [options])
  18. Accepts a filename and returns a valid filename.
  19. ### filenamify.path(input, [options])
  20. Accepts a path and returns the path with a valid filename.
  21. #### input
  22. Type: `string`
  23. #### options
  24. ##### replacement
  25. Type: `string`<br>
  26. Default: `'!'`
  27. String to use as replacement for reserved filename characters.
  28. Cannot contain: `<` `>` `:` `"` `/` `\` `|` `?` `*`
  29. ## Related
  30. - [filenamify-url](https://github.com/sindresorhus/filenamify-url) - Convert a URL to a valid filename
  31. - [valid-filename](https://github.com/sindresorhus/valid-filename) - Check if a string is a valid filename
  32. - [unused-filename](https://github.com/sindresorhus/unused-filename) - Get a unused filename by appending a number if it exists
  33. - [slugify](https://github.com/sindresorhus/slugify) - Slugify a string
  34. ## License
  35. MIT © [Sindre Sorhus](https://sindresorhus.com)