Gathering detailed insights and metrics for content-type
Gathering detailed insights and metrics for content-type
Gathering detailed insights and metrics for content-type
Gathering detailed insights and metrics for content-type
npm install content-type
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
Node Version
NPM Version
131 Stars
117 Commits
27 Forks
16 Watching
1 Branches
27 Contributors
Updated on 17 Aug 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-6.8%
6,051,296
Compared to previous day
Last week
2.1%
35,679,573
Compared to previous week
Last month
8%
148,203,836
Compared to previous month
Last year
9.2%
1,544,472,847
Compared to previous year
Create and parse HTTP Content-Type header according to RFC 7231
1$ npm install content-type
1var contentType = require('content-type')
1var obj = contentType.parse('image/svg+xml; charset=utf-8')
Parse a Content-Type
header. This will return an object with the following
properties (examples are shown for the string 'image/svg+xml; charset=utf-8'
):
type
: The media type (the type and subtype, always lower case).
Example: 'image/svg+xml'
parameters
: An object of the parameters in the media type (name of parameter
always lower case). Example: {charset: 'utf-8'}
Throws a TypeError
if the string is missing or invalid.
1var obj = contentType.parse(req)
Parse the Content-Type
header from the given req
. Short-cut for
contentType.parse(req.headers['content-type'])
.
Throws a TypeError
if the Content-Type
header is missing or invalid.
1var obj = contentType.parse(res)
Parse the Content-Type
header set on the given res
. Short-cut for
contentType.parse(res.getHeader('content-type'))
.
Throws a TypeError
if the Content-Type
header is missing or invalid.
1var str = contentType.format({ 2 type: 'image/svg+xml', 3 parameters: { charset: 'utf-8' } 4})
Format an object into a Content-Type
header. This will return a string of the
content type for the given object with the following properties (examples are
shown that produce the string 'image/svg+xml; charset=utf-8'
):
type
: The media type (will be lower-cased). Example: 'image/svg+xml'
parameters
: An object of the parameters in the media type (name of the
parameter will be lower-cased). Example: {charset: 'utf-8'}
Throws a TypeError
if the object contains an invalid type or parameter names.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
Found 3/30 approved changesets -- score normalized to 1
Reason
0 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
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