Gathering detailed insights and metrics for content-type-parser
Gathering detailed insights and metrics for content-type-parser
Gathering detailed insights and metrics for content-type-parser
Gathering detailed insights and metrics for content-type-parser
tm-content-parser
Trinity Mirror Content Type Parser
formzilla
Fastify plugin for parsing multipart/form data
mime-content
A simple mime-type based string parser
req-parser
A middleware function for parsing request bodies in Express.js. It automatically detects the content type and parses the body accordingly.
Parses, serializes, and manipulates MIME types, according to the WHATWG MIME Sniffing Standard
npm install content-type-parser
Typescript
Module System
Node Version
NPM Version
99.8
Supply Chain
84.4
Quality
74.8
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
88 Stars
35 Commits
19 Forks
7 Watchers
1 Branches
9 Contributors
Updated on Jul 04, 2025
Latest Version
1.0.2
Package Id
content-type-parser@1.0.2
Size
3.07 kB
NPM Version
5.4.2
Node Version
8.6.0
Published on
Oct 23, 2017
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
Content-Type
Header StringsThis package will parse the Content-Type
header field into an introspectable data structure, whose parameters can be manipulated:
1const contentTypeParser = require("content-type-parser"); 2 3const contentType = contentTypeParser(`Text/HTML;Charset="utf-8"`); 4 5console.assert(contentType.toString() === "text/html;charset=utf-8"); 6 7console.assert(contentType.type === "text"); 8console.assert(contentType.subtype === "html"); 9console.assert(contentType.get("charset") === "utf-8"); 10 11contentType.set("charset", "windows-1252"); 12console.assert(contentType.get("charset") === "windows-1252"); 13console.assert(contentType.toString() === "text/html;charset=windows-1252"); 14 15console.assert(contentType.isHTML() === true); 16console.assert(contentType.isXML() === false); 17console.assert(contentType.isText() === true);
Note how parsing will lowercase the type, subtype, and parameter name tokens (but not parameter values).
If the passed string cannot be parsed as a content-type, contentTypeParser
will return null
.
ContentType
instance APIThis package's main module's default export will return an instance of the ContentType
class, which has the following public APIs:
type
: the top-level media type, e.g. "text"
subtype
: the subtype, e.g. "html"
parameterList
: an array of { separator, key, value }
pairs representing the parameters. The separator
field contains any whitespace, not just the ;
character.In general you should not directly manipulate parameterList
. Instead, use the following APIs:
get("key")
: returns the value of the parameter with the given key, or undefined
if no such parameter is presentset("key", "value")
: adds the given key/value pair to the parameter list, or overwrites the existing value if an entry already existedBoth of these will lowercase the keys.
isHTML()
: returns true if this instance's MIME type is the HTML MIME type, "text/html"
isXML()
: returns true if this instance's MIME type is an XML MIME typeisText()
: returns true if this instance's top-level media type is "text"
toString()
will return a canonicalized representation of the content-type, re-built from the parsed componentsThis package was originally based on the excellent work of @nicolashenry, in jsdom. It has since been pulled out into this separate package.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
2 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 2/27 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
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
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 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