Comparing version 3.0.7 to 3.1.0
@@ -9,7 +9,5 @@ // Generated by CoffeeScript 1.12.7 | ||
(function() { | ||
var MimeTypes, defineProperty, extractTypeRegExp, isArray, isFunction, isString, mediaTyper, minimatch, path, textTypeRegExp, | ||
var MimeTypes, defineProperty, extractTypeRegExp, isArray, isFunction, isString, minimatch, path, textTypeRegExp, | ||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; | ||
mediaTyper = require('media-typer'); | ||
minimatch = require('minimatch'); | ||
@@ -86,16 +84,24 @@ | ||
MimeTypes.prototype.charset = function(type) { | ||
var obj, result; | ||
var match, mime, result; | ||
if (type && isString(type)) { | ||
try { | ||
obj = mediaTyper.parse(type); | ||
result = obj.parameters.charset; | ||
if (!result) { | ||
obj.parameters = void 0; | ||
type = mediaTyper.format(obj); | ||
result = this[type] && this[type].charset; | ||
} | ||
if (!result && obj.type === 'text') { | ||
result = 'utf-8'; | ||
} | ||
} catch (error) {} | ||
match = extractTypeRegExp.exec(type); | ||
mime = match && this[match[1].toLowerCase()]; | ||
if (mime) { | ||
result = mime.charset; | ||
} | ||
if (!result && textTypeRegExp.test(match[1])) { | ||
result = 'utf-8'; | ||
} | ||
/* | ||
try | ||
obj = mediaTyper.parse(type) | ||
result = obj.parameters.charset | ||
if not result | ||
obj.parameters = undefined | ||
type = mediaTyper.format(obj) | ||
result = @[type] and @[type].charset | ||
* default text/* to utf-8 | ||
result = 'utf-8' if !result and obj.type is 'text' | ||
*/ | ||
} | ||
@@ -163,3 +169,14 @@ return result; | ||
if (extension) { | ||
result = this.types[extension]; | ||
if (/[*?!+|{]/.test(extension)) { | ||
result = Object.keys(this.types).filter(function(name) { | ||
return minimatch(name, extension); | ||
}); | ||
result = result.length ? result.map((function(_this) { | ||
return function(ext) { | ||
return _this.types[ext]; | ||
}; | ||
})(this)) : void 0; | ||
} else { | ||
result = this.types[extension]; | ||
} | ||
} | ||
@@ -166,0 +183,0 @@ } |
{ | ||
"name": "mime-type", | ||
"description": "the custom more powerful mime-type utility can work with mime-db.", | ||
"version": "3.0.7", | ||
"version": "3.1.0", | ||
"contributors": [ | ||
@@ -19,3 +19,2 @@ "Riceball LEE https://github.com/snowyu", | ||
"dependencies": { | ||
"media-typer": "^0.3.0", | ||
"minimatch": "^3.0.4", | ||
@@ -22,0 +21,0 @@ "path.js": "^1.0.7", |
Sorry, the diff of this file is not supported yet
31006
3
437
- Removedmedia-typer@^0.3.0
- Removedmedia-typer@0.3.0(transitive)