Gathering detailed insights and metrics for sanitize-filename-ts
Gathering detailed insights and metrics for sanitize-filename-ts
Gathering detailed insights and metrics for sanitize-filename-ts
Gathering detailed insights and metrics for sanitize-filename-ts
Sanitize string for use as filename, written in Typescript
npm install sanitize-filename-ts
Typescript
Module System
Node Version
NPM Version
91.8
Supply Chain
99.4
Quality
78.8
Maintenance
100
Vulnerability
99.3
License
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
NOASSERTION License
4 Stars
105 Commits
2 Forks
1 Watchers
2 Branches
2 Contributors
Updated on Apr 18, 2025
Latest Version
1.0.2
Package Id
sanitize-filename-ts@1.0.2
Unpacked Size
7.55 kB
Size
3.51 kB
File Count
5
NPM Version
6.9.0
Node Version
10.16.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
6
Sanitize a string to be safe for use as a filename by removing directory paths and invalid characters. This package is a fork of sanitize-filename, updated and rewritten in Typescript.
npm install sanitize-filename-ts
1import { sanitize } from "sanitize-filename-ts"; 2 3// Some string that may be unsafe or invalid as a filename 4var UNSAFE_USER_INPUT = "~/.\u0000ssh/authorized_keys"; 5 6// Sanitize the string to be safe for use as a filename. 7var filename = sanitize(UNSAFE_USER_INPUT); 8// -> "~.sshauthorized_keys"
sanitize-filename-ts removes the following:
0x00
–0x1f
and 0x80
–0x9f
)/
, ?
, <
, >
, \
, :
, *
, |
, and
"
).
and ..
)CON
, PRN
, AUX
, NUL
, COM1
,
COM2
, COM3
, COM4
, COM5
, COM6
, COM7
, COM8
, COM9
,
LPT1
, LPT2
, LPT3
, LPT4
, LPT5
, LPT6
, LPT7
, LPT8
, and
LPT9
)The resulting string is truncated to 255 bytes in length. The string will not contain any directory paths and will be safe to use as a filename.
""
ResultAn empty string ""
can be returned. For example:
1import { sanitize } from "sanitize-filename-ts"; 2sanitize(".."); 3// -> ""
Two different inputs can return the same value. For example:
1import { sanitize } from "sanitize-filename-ts"; 2sanitize("file?"); 3// -> "file" 4sanitize("*file*"); 5// -> "file"
Sanitized filenames will be safe for use on modern Windows, OS X, and
Unix file systems (NTFS
, ext
, etc.).
FAT
8.3 filenames are not supported.
The test program will use various strings (including the Big List of
Naughty Strings) to create files in the working directory. Run
npm test
to run tests against your file system.
sanitize(inputString, [options])
Sanitize inputString
by removing or replacing invalid characters.
Options:
options.replacement
: optional, string/function, default: ""
. If passed
as a string, it's used as the replacement for invalid characters. If passed as
a function, the function will be called with the invalid characters and it's
return value will be used as the replacement. See String.prototype.replace
for more info.No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
5 existing vulnerabilities detected
Details
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More