Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 24, 2024 via pnpm

sanitize-filename 1.6.3

Sanitize a string for use as a filename
Package summary
Share
2
issues
2
low severity
license
2
2
licenses
2
WTFPL
1
WTFPL OR ISC
Package created
30 Aug 2013
Version published
26 Aug 2019
Maintainers
1
Total deps
3
Direct deps
1
License
WTFPL OR ISC

Issues

2

2 low severity issues

low
Recommendation: Read and validate the license terms
via: truncate-utf8-bytes@1.0.2
Recommendation: Read and validate the license terms
via: truncate-utf8-bytes@1.0.2
Collapse
Expand

Licenses

Do What The F*ck You Want To Public License

Permissive
Not OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
sublicense
distribute
modify
Cannot
Must
rename
2 Packages, Including:
truncate-utf8-bytes@1.0.2
utf8-byte-length@1.0.4

WTFPL OR ISC

Permissive
1 Packages, Including:
sanitize-filename@1.6.3
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

1
All Dependencies CSV
β“˜ This is a list of sanitize-filename 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
truncate-utf8-bytes1.0.22.18 kBWTFPL
prod
2

Visualizations

Frequently Asked Questions

What does sanitize-filename do?

The sanitize-filename is a JavaScript npm package designed to sanitize a string for safe usage as a filename. It achieves this by removing directory paths and invalid characters. This makes the package particularly useful when dealing with user-generated input that may contain unsafe or invalid strings for filenames. The resulting string will not contain any directory paths, making it safe for use as a filename.

How do you use sanitize-filename?

To use the sanitize-filename package in your JavaScript project, you need to first install it via npm using the command npm install sanitize-filename. Once installed, you can require it in your JavaScript file and use its main function to sanitize a potentially unsafe filename. Here is a basic example of how to use it:

var sanitize = require("sanitize-filename");

// Assume you have a string that may be unsafe as a filename
var UNSAFE_USER_INPUT = "~/.\u0000ssh/authorized_keys";

var filename = sanitize(UNSAFE_USER_INPUT);
// The result, assigned to the variable filename, is a sanitized version of the unsafe string.
// In this example, the result would be: "~.sshauthorized_keys"

In addition to the base functionality, you can also pass an options object to the sanitize function to specify a replacement for invalid characters. The replacement can be either a string or a function.

Where are the sanitize-filename docs?

The detailed documentation and usage guidelines for sanitize-filename can be found here. The page includes installation instructions, examples, and information on the algorithm used by the package to sanitize filenames, covering various edge cases and specificities of different operating systems. You can also find details about available options and their usage. This package is hosted on GitHub, and the repository can be accessed at git+ssh://git@github.com/parshap/node-sanitize-filename.git.