New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sanitize-basename

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sanitize-basename

Sanitize a file name for cross-platform validity.

1.0.0
Source
npm
Version published
Weekly downloads
339
-7.88%
Maintainers
1
Weekly downloads
 
Created
Source

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
  • unsanitize-basename: Unsanitize a file name, the inverse of this library.

License

MIT © Fabio Spampinato

Keywords

sanitize

FAQs

Package last updated on 09 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts