Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mime-types

Package Overview
Dependencies
Maintainers
0
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mime-types - npm Package Compare versions

Comparing version 2.1.35 to 3.0.0

mimeScore.js

19

HISTORY.md

@@ -0,1 +1,20 @@

3.0.0 / 2024-08-31
===================
* Drop support for node <18
* deps: mime-db@1.53.0
* resolve extension conflicts with mime-score (#119)
* asc -> application/pgp-signature is now application/pgp-keys
* mpp -> application/vnd.ms-project is now application/dash-patch+xml
* ac -> application/vnd.nokia.n-gage.ac+xml is now application/pkix-attr-cert
* bdoc -> application/x-bdoc is now application/bdoc
* wmz -> application/x-msmetafile is now application/x-ms-wmz
* xsl -> application/xslt+xml is now application/xml
* wav -> audio/wave is now audio/wav
* rtf -> text/rtf is now application/rtf
* xml -> text/xml is now application/xml
* mp4 -> video/mp4 is now application/mp4
* mpg4 -> video/mp4 is now application/mp4
2.1.35 / 2022-03-12

@@ -2,0 +21,0 @@ ===================

61

index.js

@@ -17,2 +17,3 @@ /*!

var extname = require('path').extname
var mimeScore = require('./mimeScore')

@@ -39,2 +40,3 @@ /**

exports.types = Object.create(null)
exports._extensionConflicts = []

@@ -85,5 +87,3 @@ // Populate the extensions/types maps

var mime = str.indexOf('/') === -1
? exports.lookup(str)
: str
var mime = str.indexOf('/') === -1 ? exports.lookup(str) : str

@@ -143,3 +143,3 @@ if (!mime) {

.toLowerCase()
.substr(1)
.slice(1)

@@ -159,5 +159,2 @@ if (!extension) {

function populateMaps (extensions, types) {
// source preference (least -> most)
var preference = ['nginx', 'apache', undefined, 'iana']
Object.keys(db).forEach(function forEachMimeType (type) {

@@ -177,18 +174,44 @@ var mime = db[type]

var extension = exts[i]
types[extension] = _preferredType(extension, types[extension], type)
if (types[extension]) {
var from = preference.indexOf(db[types[extension]].source)
var to = preference.indexOf(mime.source)
if (types[extension] !== 'application/octet-stream' &&
(from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) {
// skip the remapping
continue
}
// DELETE (eventually): Capture extension->type maps that change as a
// result of switching to mime-score. This is just to help make reviewing
// PR #119 easier, and can be removed once that PR is approved.
const legacyType = _preferredTypeLegacy(
extension,
types[extension],
type
)
if (legacyType !== types[extension]) {
exports._extensionConflicts.push([extension, legacyType, types[extension]])
}
// set the extension -> mime
types[extension] = type
}
})
}
// Resolve type conflict using mime-score
function _preferredType (ext, type0, type1) {
var score0 = type0 ? mimeScore(type0, db[type0].source) : 0
var score1 = type1 ? mimeScore(type1, db[type1].source) : 0
return score0 > score1 ? type0 : type1
}
// Resolve type conflict using pre-mime-score logic
function _preferredTypeLegacy (ext, type0, type1) {
var SOURCE_RANK = ['nginx', 'apache', undefined, 'iana']
var score0 = type0 ? SOURCE_RANK.indexOf(db[type0].source) : 0
var score1 = type1 ? SOURCE_RANK.indexOf(db[type1].source) : 0
if (
exports.types[extension] !== 'application/octet-stream' &&
(score0 > score1 ||
(score0 === score1 &&
exports.types[extension]?.slice(0, 12) === 'application/'))
) {
return type0
}
return score0 > score1 ? type0 : type1
}
{
"name": "mime-types",
"description": "The ultimate javascript content-type utility.",
"version": "2.1.35",
"version": "3.0.0",
"contributors": [

@@ -17,13 +17,13 @@ "Douglas Christopher Wilson <doug@somethingdoug.com>",

"dependencies": {
"mime-db": "1.52.0"
"mime-db": "^1.53.0"
},
"devDependencies": {
"eslint": "7.32.0",
"eslint": "8.33.0",
"eslint-config-standard": "14.1.1",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-markdown": "2.2.1",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-markdown": "3.0.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "5.2.0",
"eslint-plugin-promise": "6.1.1",
"eslint-plugin-standard": "4.1.0",
"mocha": "9.2.2",
"mocha": "10.2.0",
"nyc": "15.1.0"

@@ -34,3 +34,4 @@ },

"LICENSE",
"index.js"
"index.js",
"mimeScore.js"
],

@@ -37,0 +38,0 @@ "engines": {

@@ -32,2 +32,15 @@ # mime-types

## Note on MIME Type Data and Semver
This package considers the programmatic api as the semver compatibility. Additionally, the package which provides the MIME data
for this package (`mime-db`) *also* considers it's programmatic api as the semver contract. This means the MIME type resolution is *not* considered
in the semver bumps.
In the past the version of `mime-db` was pinned to give two decision points when adopting MIME data changes. This is no longer true. We still update the
`mime-db` package here as a `minor` release when necessary, but will use a `^` range going forward. This means that if you want to pin your `mime-db` data
you will need to do it in your application. While this expectation was not set in docs until now, it is how the pacakge operated, so we do not feel this is
a breaking change.
If you wish to pin your `mime-db` version you can do that with overrides via your package manager of choice. See their documentation for how to correctly configure that.
## Adding Types

@@ -34,0 +47,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc