Comparing version 1.2.11 to 1.3.0
10
mime.js
@@ -24,3 +24,2 @@ var path = require('path'); | ||
var exts = map[type]; | ||
for (var i = 0; i < exts.length; i++) { | ||
@@ -51,3 +50,2 @@ if (process.env.DEBUG_MIME && this.types[exts]) { | ||
Mime.prototype.load = function(file) { | ||
this._loading = file; | ||
@@ -90,9 +88,5 @@ // Read file and split into lines | ||
// Load local copy of | ||
// http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types | ||
mime.load(path.join(__dirname, 'types/mime.types')); | ||
// Define built-in types | ||
mime.define(require('./types.json')); | ||
// Load additional types from node.js community | ||
mime.load(path.join(__dirname, 'types/node.types')); | ||
// Default type | ||
@@ -99,0 +93,0 @@ mime.default_type = mime.lookup('bin'); |
@@ -7,2 +7,5 @@ { | ||
}, | ||
"scripts": { | ||
"test": "node test.js" | ||
}, | ||
"contributors": [ | ||
@@ -15,10 +18,28 @@ { | ||
], | ||
"dependencies": {}, | ||
"dependencies": { | ||
"mime-db": "^1.2.0" | ||
}, | ||
"description": "A comprehensive library for mime-type mapping", | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://raw.github.com/broofa/node-mime/master/LICENSE" | ||
} | ||
], | ||
"scripts": { | ||
"install": "node build/build.js > types.json", | ||
"test": "node build/test.js" | ||
}, | ||
"devDependencies": {}, | ||
"keywords": ["util", "mime"], | ||
"keywords": [ | ||
"util", | ||
"mime" | ||
], | ||
"main": "mime.js", | ||
"name": "mime", | ||
"repository": {"url": "https://github.com/broofa/node-mime", "type": "git"}, | ||
"version": "1.2.11" | ||
"repository": { | ||
"url": "https://github.com/broofa/node-mime", | ||
"type": "git" | ||
}, | ||
"version": "1.3.0" | ||
} |
# mime | ||
Comprehensive MIME type mapping API. Includes all 600+ types and 800+ extensions defined by the Apache project, plus additional types submitted by the node.js community. | ||
Comprehensive MIME type mapping API based on mime-db module. | ||
@@ -9,4 +9,10 @@ ## Install | ||
npm install mime | ||
```sh | ||
npm install mime | ||
``` | ||
## Contributing / Testing | ||
Use `npm run test` to verify changes prior to submitting PR's | ||
## API - Queries | ||
@@ -17,8 +23,10 @@ | ||
var mime = require('mime'); | ||
```js | ||
var mime = require('mime'); | ||
mime.lookup('/path/to/file.txt'); // => 'text/plain' | ||
mime.lookup('file.txt'); // => 'text/plain' | ||
mime.lookup('.TXT'); // => 'text/plain' | ||
mime.lookup('htm'); // => 'text/html' | ||
mime.lookup('/path/to/file.txt'); // => 'text/plain' | ||
mime.lookup('file.txt'); // => 'text/plain' | ||
mime.lookup('.TXT'); // => 'text/plain' | ||
mime.lookup('htm'); // => 'text/html' | ||
``` | ||
@@ -31,4 +39,6 @@ ### mime.default_type | ||
mime.extension('text/html'); // => 'html' | ||
mime.extension('application/octet-stream'); // => 'bin' | ||
```js | ||
mime.extension('text/html'); // => 'html' | ||
mime.extension('application/octet-stream'); // => 'bin' | ||
``` | ||
@@ -39,3 +49,5 @@ ### mime.charsets.lookup() | ||
mime.charsets.lookup('text/plain'); // => 'UTF-8' | ||
```js | ||
mime.charsets.lookup('text/plain'); // => 'UTF-8' | ||
``` | ||
@@ -46,3 +58,3 @@ (The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.) | ||
The following APIs allow you to add your own type mappings within your project. If you feel a type should be included as part of node-mime, see [requesting new types](https://github.com/broofa/node-mime/wiki/Requesting-New-Types). | ||
Custom type mappings can be added on a per-project basis via the following APIs. | ||
@@ -53,13 +65,17 @@ ### mime.define() | ||
mime.define({ | ||
'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'], | ||
'application/x-my-type': ['x-mt', 'x-mtt'], | ||
// etc ... | ||
}); | ||
```js | ||
mime.define({ | ||
'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'], | ||
'application/x-my-type': ['x-mt', 'x-mtt'], | ||
// etc ... | ||
}); | ||
mime.lookup('x-sft'); // => 'text/x-some-format' | ||
mime.lookup('x-sft'); // => 'text/x-some-format' | ||
``` | ||
The first entry in the extensions array is returned by `mime.extension()`. E.g. | ||
mime.extension('text/x-some-format'); // => 'x-sf' | ||
```js | ||
mime.extension('text/x-some-format'); // => 'x-sf' | ||
``` | ||
@@ -70,4 +86,5 @@ ### mime.load(filepath) | ||
mime.load('./my_project.types'); | ||
```js | ||
mime.load('./my_project.types'); | ||
``` | ||
The .types file format is simple - See the `types` dir for examples. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
84
9162
1
145
1
+ Addedmime-db@^1.2.0
+ Addedmime-db@1.53.0(transitive)