Gathering detailed insights and metrics for mime-content
Gathering detailed insights and metrics for mime-content
Gathering detailed insights and metrics for mime-content
Gathering detailed insights and metrics for mime-content
mime-types
The ultimate javascript content-type utility.
compressible
Compressible Content-Type / mime checking
cache-content-type
Create a full Content-Type header given a MIME type or extension and cache the result
whatwg-mimetype
Parses, serializes, and manipulates MIME types, according to the WHATWG MIME Sniffing Standard
npm install mime-content
Typescript
Module System
Node Version
NPM Version
70.8
Supply Chain
96.2
Quality
83.3
Maintenance
50
Vulnerability
99.6
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
37 Commits
17 Watchers
2 Branches
10 Contributors
Updated on Jun 11, 2025
Latest Version
0.0.10
Package Id
mime-content@0.0.10
Unpacked Size
15.32 kB
Size
5.66 kB
File Count
17
NPM Version
10.8.2
Node Version
18.20.5
Published on
Jan 15, 2025
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
4
1
A node.js module for parsing strings based on MIME Type.
This module supports parsing strings for a small handful of common MIME Types. Pull requests for adding additional types are welcome.
After parsing a HTML string, CSS selectors can be used to query the parsed content. The cheerio module is used to query the DOM. Selectors supported by JQuery can be used.
Use the toString()
function to retrieve the un-parsed content.
1var content = require('mime-content'); 2 3var html = content('<html><body><h1 class="big">Header!</h1></body></html>', 'text/html'); 4 5html('h1.big').text(); 6=> 'Header!'
After parsing a JSON string, a regular object is returned. Use the toString()
function on that object to retrieve
the un-parsed content.
1var content = require('mime-content'); 2 3var json = content('{"foo":"bar"}', 'application/json'); 4 5json.foo 6=> 'bar'
Both the application/xml and text/xml MIME Types are supported.
After parsing a XML string, the xmldom document is available. Also, XPath support is provided by the xpath module. All DOM 3 XPath expressions are supported.
By default, the XML parser assumes your XPath expression is looking for a single DOM node so it returns the first match
in the document. If you'd like all matching nodes instead, use the second optional boolean parameter with your query. Pass
true
to return all matching nodes.
1var content = require('mime-content'); 2 3var xml = content('<people><person id="123"><name>Bob Smith</name></person><person id="456"><name>Jimmy Dean</name></person></people>', 'text/xml'); 4 5xml.xpath('/people/person/name/text()').data; 6=> 'Bob Smith' 7 8xml.xpath('/people/person/name/text()', true).map(function(text) { 9 return text.data; 10}); 11=> ['Bob Smith', 'Jimmy Dean'] 12 13xml.xpath('/people/person/@id', true).map(function(attr) { 14 return attr.value; 15}); 16=> ['123', '456']
The toObject()
function uses xml2js to return an object representation
of the XML. This function accepts an options object that is passed directly to the xml2js Parser. See the xml2js Readme for
the supported options.
1var xml = content('<people><person id="123"><name>Bob Smith</name></person><person id="456"><name>Jimmy Dean</name></person></people>', 'text/xml'); 2xml.toObject({explicitArray: false, explicitRoot: false, mergeAttrs: true}); 3=> 4{ 5 person: [ 6 { id: '123', name: 'Bob Smith' }, 7 { id: '456', name: 'Jimmy Dean' } 8 ] 9}
After parsing a application/x-www-form-urlencoded
string, a regular object is returned.
1var content = require('mime-content'); 2 3var qs = content('foo=bar&foo=baz&baz=bip', 'application/x-www-form-urlencoded'); 4 5qs.foo 6=> ['bar', 'baz'] 7 8qs.baz 9=> 'bip'
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
SAST tool detected but not run on all commits
Details
Reason
Found 4/30 approved changesets -- score normalized to 1
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
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
license file not detected
Details
Reason
security policy file not detected
Details
Score
Last Scanned on 2025-07-14
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