update
This commit is contained in:
+28
@@ -2,6 +2,34 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## [2.6.0](https://github.com/broofa/mime/compare/v2.5.2...v2.6.0) (2021-11-02)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* mime-db@1.50.0 ([cef0cc4](https://github.com/broofa/mime/commit/cef0cc484ff6d05ff1e12b54ca3e8b856fbc14d8))
|
||||
|
||||
### [2.5.2](https://github.com/broofa/mime/compare/v2.5.0...v2.5.2) (2021-02-17)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* update to mime-db@1.46.0, fixes [#253](https://github.com/broofa/mime/issues/253) ([f10e6aa](https://github.com/broofa/mime/commit/f10e6aa62e1356de7e2491d7fb4374c8dac65800))
|
||||
|
||||
## [2.5.0](https://github.com/broofa/mime/compare/v2.4.7...v2.5.0) (2021-01-16)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* improved CLI ([#244](https://github.com/broofa/mime/issues/244)) ([c8a8356](https://github.com/broofa/mime/commit/c8a8356e3b27f3ef46b64b89b428fdb547b14d5f))
|
||||
|
||||
### [2.4.7](https://github.com/broofa/mime/compare/v2.4.6...v2.4.7) (2020-12-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* update to latest mime-db ([43b09ef](https://github.com/broofa/mime/commit/43b09eff0233eacc449af2b1f99a19ba9e104a44))
|
||||
|
||||
### [2.4.6](https://github.com/broofa/mime/compare/v2.4.5...v2.4.6) (2020-05-27)
|
||||
|
||||
|
||||
|
||||
+14
-12
@@ -8,7 +8,7 @@ function Mime() {
|
||||
this._types = Object.create(null);
|
||||
this._extensions = Object.create(null);
|
||||
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
this.define(arguments[i]);
|
||||
}
|
||||
|
||||
@@ -37,16 +37,18 @@ function Mime() {
|
||||
* @param force (Boolean) if true, force overriding of existing definitions
|
||||
*/
|
||||
Mime.prototype.define = function(typeMap, force) {
|
||||
for (var type in typeMap) {
|
||||
var extensions = typeMap[type].map(function(t) {return t.toLowerCase()});
|
||||
for (let type in typeMap) {
|
||||
let extensions = typeMap[type].map(function(t) {
|
||||
return t.toLowerCase();
|
||||
});
|
||||
type = type.toLowerCase();
|
||||
|
||||
for (var i = 0; i < extensions.length; i++) {
|
||||
var ext = extensions[i];
|
||||
for (let i = 0; i < extensions.length; i++) {
|
||||
const ext = extensions[i];
|
||||
|
||||
// '*' prefix = not the preferred type for this extension. So fixup the
|
||||
// extension, and skip it.
|
||||
if (ext[0] == '*') {
|
||||
if (ext[0] === '*') {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -64,8 +66,8 @@ Mime.prototype.define = function(typeMap, force) {
|
||||
|
||||
// Use first extension as default
|
||||
if (force || !this._extensions[type]) {
|
||||
var ext = extensions[0];
|
||||
this._extensions[type] = (ext[0] != '*') ? ext : ext.substr(1)
|
||||
const ext = extensions[0];
|
||||
this._extensions[type] = (ext[0] !== '*') ? ext : ext.substr(1);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -75,11 +77,11 @@ Mime.prototype.define = function(typeMap, force) {
|
||||
*/
|
||||
Mime.prototype.getType = function(path) {
|
||||
path = String(path);
|
||||
var last = path.replace(/^.*[/\\]/, '').toLowerCase();
|
||||
var ext = last.replace(/^.*\./, '').toLowerCase();
|
||||
let last = path.replace(/^.*[/\\]/, '').toLowerCase();
|
||||
let ext = last.replace(/^.*\./, '').toLowerCase();
|
||||
|
||||
var hasPath = last.length < path.length;
|
||||
var hasDot = ext.length < last.length - 1;
|
||||
let hasPath = last.length < path.length;
|
||||
let hasDot = ext.length < last.length - 1;
|
||||
|
||||
return (hasDot || !hasPath) && this._types[ext] || null;
|
||||
};
|
||||
|
||||
+2
-2
@@ -34,14 +34,14 @@ E.g. For the full version:
|
||||
<script src="https://wzrd.in/standalone/mime@latest"></script>
|
||||
<script>
|
||||
mime.getType(...); // etc.
|
||||
<script>
|
||||
</script>
|
||||
|
||||
Or, for the `mime/lite` version:
|
||||
|
||||
<script src="https://wzrd.in/standalone/mime%2flite@latest"></script>
|
||||
<script>
|
||||
mimelite.getType(...); // (Note `mimelite` here)
|
||||
<script>
|
||||
</script>
|
||||
|
||||
## Quick Start
|
||||
|
||||
|
||||
+39
-3
@@ -2,9 +2,45 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var mime = require('.');
|
||||
var file = process.argv[2];
|
||||
var type = mime.getType(file);
|
||||
process.title = 'mime';
|
||||
let mime = require('.');
|
||||
let pkg = require('./package.json');
|
||||
let args = process.argv.splice(2);
|
||||
|
||||
if (args.includes('--version') || args.includes('-v') || args.includes('--v')) {
|
||||
console.log(pkg.version);
|
||||
process.exit(0);
|
||||
} else if (args.includes('--name') || args.includes('-n') || args.includes('--n')) {
|
||||
console.log(pkg.name);
|
||||
process.exit(0);
|
||||
} else if (args.includes('--help') || args.includes('-h') || args.includes('--h')) {
|
||||
console.log(pkg.name + ' - ' + pkg.description + '\n');
|
||||
console.log(`Usage:
|
||||
|
||||
mime [flags] [path_or_extension]
|
||||
|
||||
Flags:
|
||||
--help, -h Show this message
|
||||
--version, -v Display the version
|
||||
--name, -n Print the name of the program
|
||||
|
||||
Note: the command will exit after it executes if a command is specified
|
||||
The path_or_extension is the path to the file or the extension of the file.
|
||||
|
||||
Examples:
|
||||
mime --help
|
||||
mime --version
|
||||
mime --name
|
||||
mime -v
|
||||
mime src/log.js
|
||||
mime new.py
|
||||
mime foo.sh
|
||||
`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
let file = args[0];
|
||||
let type = mime.getType(file);
|
||||
|
||||
process.stdout.write(type + '\n');
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
var Mime = require('./Mime');
|
||||
let Mime = require('./Mime');
|
||||
module.exports = new Mime(require('./types/standard'), require('./types/other'));
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
var Mime = require('./Mime');
|
||||
let Mime = require('./Mime');
|
||||
module.exports = new Mime(require('./types/standard'));
|
||||
|
||||
+19
-21
@@ -1,34 +1,32 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"mime@2.4.6",
|
||||
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
|
||||
"mime@2.6.0",
|
||||
"/home/node/nuxt"
|
||||
]
|
||||
],
|
||||
"_from": "mime@2.4.6",
|
||||
"_id": "mime@2.4.6",
|
||||
"_from": "mime@2.6.0",
|
||||
"_id": "mime@2.6.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA==",
|
||||
"_integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==",
|
||||
"_location": "/mime",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "mime@2.4.6",
|
||||
"raw": "mime@2.6.0",
|
||||
"name": "mime",
|
||||
"escapedName": "mime",
|
||||
"rawSpec": "2.4.6",
|
||||
"rawSpec": "2.6.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.4.6"
|
||||
"fetchSpec": "2.6.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/postcss-url",
|
||||
"/url-loader",
|
||||
"/webpack-dev-middleware"
|
||||
"/postcss-url"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/mime/-/mime-2.4.6.tgz",
|
||||
"_spec": "2.4.6",
|
||||
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
|
||||
"_resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz",
|
||||
"_spec": "2.6.0",
|
||||
"_where": "/home/node/nuxt",
|
||||
"author": {
|
||||
"name": "Robert Kieffer",
|
||||
"email": "robert@broofa.com",
|
||||
@@ -45,14 +43,14 @@
|
||||
"description": "A comprehensive library for mime-type mapping",
|
||||
"devDependencies": {
|
||||
"benchmark": "*",
|
||||
"chalk": "*",
|
||||
"eslint": "*",
|
||||
"mime-db": "1.44.0",
|
||||
"chalk": "4.1.2",
|
||||
"eslint": "8.1.0",
|
||||
"mime-db": "1.50.0",
|
||||
"mime-score": "1.2.0",
|
||||
"mime-types": "2.1.27",
|
||||
"mocha": "7.1.2",
|
||||
"mime-types": "2.1.33",
|
||||
"mocha": "9.1.3",
|
||||
"runmd": "*",
|
||||
"standard-version": "7.1.0"
|
||||
"standard-version": "9.3.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0.0"
|
||||
@@ -82,5 +80,5 @@
|
||||
"release": "standard-version",
|
||||
"test": "mocha src/test.js"
|
||||
},
|
||||
"version": "2.4.6"
|
||||
"version": "2.6.0"
|
||||
}
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user