compressible
Advanced tools
Comparing version 0.1.1 to 0.2.0
18
index.js
@@ -6,7 +6,19 @@ module.exports = compressible | ||
compressible.regex | ||
compressible.regexp = /json|text|javascript|dart|ecmascript|xml|x-font-ttf|ms-opentype|ms-fontobject/ | ||
compressible.regex = | ||
compressible.regexp = /json|text|javascript|dart|ecmascript|xml/ | ||
compressible.get = get | ||
function compressible(type) { | ||
return compressible.regexp.test(type) | ||
var spec = compressible.specs[type] | ||
return spec ? spec.compressible : compressible.regex.test(type) | ||
} | ||
function get(type) { | ||
var spec = compressible.specs[type] | ||
return spec ? spec : { | ||
compressible: compressible.regex.test(type), | ||
sources: ["compressible.regex"], | ||
notes: "Automatically generated via regex." | ||
} | ||
} |
{ | ||
"name": "compressible", | ||
"description": "Compressible mime types", | ||
"version": "0.1.1", | ||
"description": "Compressible Content-Type / mime checking", | ||
"version": "0.2.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Jonathan Ong", |
# Compressible [![Build Status](https://travis-ci.org/expressjs/compressible.png)](https://travis-ci.org/expressjs/compressible) | ||
Compressible mime types. | ||
Compressible `Content-Type` / `mime` checking. | ||
## API | ||
### compressible(mime) | ||
### compressible(type) | ||
@@ -15,2 +15,7 @@ ```js | ||
### compressible.get(type) | ||
Returns the specifications object associated with the given `Content-Type`. | ||
Generates an object using the regex if none is found. | ||
### compressible.specs | ||
@@ -22,4 +27,4 @@ | ||
The regular expression that checks the `mime`. | ||
However, you should use the `compressible` instead of this regular expression in the event that we add non-regexp checks. | ||
The regular expression that checks the `Content-Type`. | ||
However, you should use `compressible(type)` instead of this regular expression due to additional non-regex checks. | ||
@@ -26,0 +31,0 @@ ## License |
@@ -1,4 +0,3 @@ | ||
[ | ||
{ | ||
"mime": "application/atom+xml", | ||
{ | ||
"application/atom+xml": { | ||
"compressible": true, | ||
@@ -10,4 +9,13 @@ "sources": [ | ||
}, | ||
{ | ||
"mime": "application/ecmascript", | ||
"application/EDI-X12": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
"application/EDIFACT": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
"application/ecmascript": { | ||
"compressible": true, | ||
@@ -17,4 +25,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/EDI-X12", | ||
"application/font-woff": { | ||
"compressible": false, | ||
@@ -24,4 +31,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/EDIFACT", | ||
"application/gzip": { | ||
"compressible": false, | ||
@@ -31,4 +37,18 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/json", | ||
"application/java-archive": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
"application/java-serialized-object": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
"application/java-vm": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
"application/javascript": { | ||
"compressible": true, | ||
@@ -38,4 +58,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/javascript", | ||
"application/json": { | ||
"compressible": true, | ||
@@ -45,10 +64,10 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/octet-stream", | ||
"application/octet-stream": { | ||
"compressible": false, | ||
"sources": [], | ||
"sources": [ | ||
"https://github.com/broofa/node-mime/blob/master/types/mime.types#L154" | ||
], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/ogg", | ||
"application/ogg": { | ||
"compressible": false, | ||
@@ -58,4 +77,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/pdf", | ||
"application/pdf": { | ||
"compressible": false, | ||
@@ -65,4 +83,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/postscript", | ||
"application/pgp-encrypted": { | ||
"compressible": false, | ||
@@ -72,5 +89,9 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/rdf+xml", | ||
"application/postscript": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
"application/rdf+xml": { | ||
"compressible": true, | ||
"sources": [ | ||
@@ -81,4 +102,3 @@ "http://en.wikipedia.org/wiki/RDF/XML" | ||
}, | ||
{ | ||
"mime": "application/rss+xml", | ||
"application/rss+xml": { | ||
"compressible": true, | ||
@@ -88,5 +108,9 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/soap+xml", | ||
"application/rtf": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
"application/soap+xml": { | ||
"compressible": true, | ||
"sources": [ | ||
@@ -97,4 +121,8 @@ "http://en.wikipedia.org/wiki/SOAP" | ||
}, | ||
{ | ||
"mime": "application/font-woff", | ||
"application/tar": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
"application/vnd.android.package-archive": { | ||
"compressible": false, | ||
@@ -104,4 +132,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/xhtml+xml", | ||
"application/vnd.dart": { | ||
"compressible": true, | ||
@@ -111,24 +138,41 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/xml", | ||
"application/vnd.google-earth.kml+xml": { | ||
"compressible": true, | ||
"sources": [ | ||
"https://developers.google.com/kml/documentation/kml_tut" | ||
], | ||
"notes": "" | ||
}, | ||
"application/vnd.google-earth.kmz": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/xml-dtd", | ||
"application/vnd.mozilla.xul+xml": { | ||
"compressible": true, | ||
"sources": [ | ||
"http://en.wikipedia.org/wiki/Document_type_definition" | ||
"http://en.wikipedia.org/wiki/XUL" | ||
], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/xop+xml", | ||
"compressible": true, | ||
"application/vnd.ms-excel": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/zip", | ||
"application/vnd.ms-fontobject": { | ||
"compressible": true, | ||
"sources": [ | ||
"http://www.phpied.com/gzip-your-font-face-files/" | ||
], | ||
"notes": "" | ||
}, | ||
"application/vnd.ms-opentype": { | ||
"compressible": true, | ||
"sources": [ | ||
"http://www.phpied.com/gzip-your-font-face-files/" | ||
], | ||
"notes": "" | ||
}, | ||
"application/vnd.ms-powerpoint": { | ||
"compressible": false, | ||
@@ -138,4 +182,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/gzip", | ||
"application/vnd.ms-xpsdocument": { | ||
"compressible": false, | ||
@@ -145,4 +188,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "audio/basic", | ||
"application/vnd.oasis.opendocument.graphics": { | ||
"compressible": false, | ||
@@ -152,4 +194,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "audio/L24", | ||
"application/vnd.oasis.opendocument.presentation": { | ||
"compressible": false, | ||
@@ -159,4 +200,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "audio/mp4", | ||
"application/vnd.oasis.opendocument.spreadsheet": { | ||
"compressible": false, | ||
@@ -166,10 +206,10 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "audio/mpeg", | ||
"application/vnd.oasis.opendocument.text": { | ||
"compressible": false, | ||
"sources": [], | ||
"sources": [ | ||
"http://en.wikipedia.org/wiki/OpenDocument_technical_specification#File_types" | ||
], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "audio/ogg", | ||
"application/vnd.openxmlformats-officedocument.presentationml.presentation": { | ||
"compressible": false, | ||
@@ -179,4 +219,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "audio/vorbis", | ||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": { | ||
"compressible": false, | ||
@@ -186,4 +225,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "audio/vnd.rn-realaudio", | ||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": { | ||
"compressible": false, | ||
@@ -193,4 +231,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "audio/vnd.wave", | ||
"application/x-7z-compressed": { | ||
"compressible": false, | ||
@@ -200,4 +237,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "audio/webm", | ||
"application/x-bzip": { | ||
"compressible": false, | ||
@@ -207,4 +243,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "image/gif", | ||
"application/x-bzip2": { | ||
"compressible": false, | ||
@@ -214,4 +249,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "image/jpeg", | ||
"application/x-deb": { | ||
"compressible": false, | ||
@@ -221,4 +255,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "image/pjpeg", | ||
"application/x-dvi": { | ||
"compressible": false, | ||
@@ -228,4 +261,10 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "image/png", | ||
"application/x-font-ttf": { | ||
"compressible": true, | ||
"sources": [ | ||
"http://www.phpied.com/gzip-your-font-face-files/" | ||
], | ||
"notes": "" | ||
}, | ||
"application/x-java-jnlp-file": { | ||
"compressible": false, | ||
@@ -235,4 +274,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "image/svg+xml", | ||
"application/x-javascript": { | ||
"compressible": true, | ||
@@ -242,4 +280,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "image/tiff", | ||
"application/x-latex": { | ||
"compressible": false, | ||
@@ -249,4 +286,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "message/http", | ||
"application/x-mpegURL": { | ||
"compressible": false, | ||
@@ -256,12 +292,8 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "message/imdn+xml", | ||
"compressible": true, | ||
"sources": [ | ||
"http://tools.ietf.org/html/rfc5438" | ||
], | ||
"application/x-pkcs1": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "message/partial", | ||
"application/x-rar-compressed": { | ||
"compressible": false, | ||
@@ -271,10 +303,8 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "message/rfc822", | ||
"compressible": false, | ||
"application/x-sh": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "model/example", | ||
"application/x-shockwave-flash": { | ||
"compressible": false, | ||
@@ -284,4 +314,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "model/iges", | ||
"application/x-stuffit": { | ||
"compressible": false, | ||
@@ -291,10 +320,8 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "model/mesh", | ||
"compressible": false, | ||
"application/x-tar": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "model/vrml", | ||
"application/x-www-form-urlencode": { | ||
"compressible": false, | ||
@@ -304,4 +331,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "model/x3d+binary", | ||
"application/x-xpinstall": { | ||
"compressible": false, | ||
@@ -311,24 +337,25 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "model/x3d+vrml", | ||
"compressible": false, | ||
"application/xhtml+xml": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "model/x3d+xml", | ||
"application/xml": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
"application/xml-dtd": { | ||
"compressible": true, | ||
"sources": [ | ||
"http://edutechwiki.unige.ch/en/X3D_file_structure" | ||
"http://en.wikipedia.org/wiki/Document_type_definition" | ||
], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "multipart/mixed", | ||
"compressible": false, | ||
"application/xop+xml": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "multipart/alternative", | ||
"application/zip": { | ||
"compressible": false, | ||
@@ -338,4 +365,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "multipart/related", | ||
"audio/L24": { | ||
"compressible": false, | ||
@@ -345,4 +371,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "multipart/form-data", | ||
"audio/basic": { | ||
"compressible": false, | ||
@@ -352,4 +377,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "multipart/signed", | ||
"audio/mp4": { | ||
"compressible": false, | ||
@@ -359,4 +383,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "multipart/encrypted", | ||
"audio/mpeg": { | ||
"compressible": false, | ||
@@ -366,52 +389,45 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "text/cmd", | ||
"compressible": true, | ||
"audio/ogg": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "text/css", | ||
"compressible": true, | ||
"audio/vnd.rn-realaudio": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "text/csv", | ||
"compressible": true, | ||
"audio/vnd.wave": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "text/html", | ||
"compressible": true, | ||
"audio/vorbis": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "text/javascript", | ||
"compressible": true, | ||
"audio/webm": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "text/plain", | ||
"compressible": true, | ||
"audio/x-aac": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "text/vcard", | ||
"compressible": true, | ||
"audio/x-caf": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "text/xml", | ||
"image/bmp": { | ||
"compressible": true, | ||
"sources": [], | ||
"sources": [ | ||
"http://stackoverflow.com/a/12770116" | ||
], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "video/mpeg", | ||
"image/gif": { | ||
"compressible": false, | ||
@@ -421,4 +437,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "video/mp4", | ||
"image/jpeg": { | ||
"compressible": false, | ||
@@ -428,4 +443,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "video/ogg", | ||
"image/pjpeg": { | ||
"compressible": false, | ||
@@ -435,4 +449,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "video/quicktime", | ||
"image/png": { | ||
"compressible": false, | ||
@@ -442,22 +455,41 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "video/webm", | ||
"compressible": false, | ||
"image/svg+xml": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "video/x-matroska", | ||
"image/tiff": { | ||
"compressible": false, | ||
"sources": [ | ||
"http://stackoverflow.com/a/12770116" | ||
], | ||
"notes": "Gains insignificant in testing." | ||
}, | ||
"image/x-icon": { | ||
"compressible": true, | ||
"sources": [ | ||
"http://en.wikipedia.org/wiki/ICO_(file_format)" | ||
], | ||
"notes": "Usually a wrapper for .bmp formated images." | ||
}, | ||
"image/x-xcf": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "video/x-ms-wmv", | ||
"message/http": { | ||
"compressible": false, | ||
"sources": [], | ||
"sources": [ | ||
"http://stackoverflow.com/a/1450163" | ||
], | ||
"notes": "It is safest to leave these uncompressed." | ||
}, | ||
"message/imdn+xml": { | ||
"compressible": true, | ||
"sources": [ | ||
"http://tools.ietf.org/html/rfc5438" | ||
], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "video/x-flv", | ||
"message/partial": { | ||
"compressible": false, | ||
@@ -467,10 +499,10 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/vnd.oasis.opendocument.text", | ||
"compressible": null, | ||
"sources": [], | ||
"message/rfc822": { | ||
"compressible": true, | ||
"sources": [ | ||
"http://en.wikipedia.org/wiki/MIME#Multipart_subtypes" | ||
], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/vnd.oasis.opendocument.spreadsheet", | ||
"model/example": { | ||
"compressible": false, | ||
@@ -480,4 +512,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/vnd.oasis.opendocument.presentation", | ||
"model/iges": { | ||
"compressible": false, | ||
@@ -487,4 +518,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/vnd.oasis.opendocument.graphics", | ||
"model/mesh": { | ||
"compressible": false, | ||
@@ -494,4 +524,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/vnd.ms-excel", | ||
"model/vrml": { | ||
"compressible": false, | ||
@@ -501,10 +530,8 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", | ||
"compressible": null, | ||
"model/x3d+binary": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/vnd.ms-powerpoint", | ||
"model/x3d+vrml": { | ||
"compressible": false, | ||
@@ -514,54 +541,59 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/vnd.ms-opentype", | ||
"model/x3d+xml": { | ||
"compressible": true, | ||
"sources": [ | ||
"http://www.phpied.com/gzip-your-font-face-files/" | ||
"http://edutechwiki.unige.ch/en/X3D_file_structure" | ||
], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/vnd.ms-fontobject", | ||
"compressible": true, | ||
"sources": [ | ||
"http://www.phpied.com/gzip-your-font-face-files/" | ||
], | ||
"multipart/alternative": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/vnd.openxmlformats-officedocument.presentationml.presentation", | ||
"compressible": null, | ||
"multipart/encrypted": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", | ||
"compressible": null, | ||
"multipart/form-data": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/vnd.mozilla.xul+xml", | ||
"multipart/mixed": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
"multipart/related": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
"multipart/signed": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
"text/cache-manifest": { | ||
"compressible": true, | ||
"sources": [ | ||
"http://en.wikipedia.org/wiki/XUL" | ||
"https://bugzilla.mozilla.org/show_bug.cgi?id=715191#c2" | ||
], | ||
"notes": "" | ||
"notes": "I think so." | ||
}, | ||
{ | ||
"mime": "application/vnd.google-earth.kml+xml", | ||
"text/calender": { | ||
"compressible": true, | ||
"sources": [ | ||
"https://developers.google.com/kml/documentation/kml_tut" | ||
"http://en.wikipedia.org/wiki/ICalendar" | ||
], | ||
"notes": "" | ||
"notes": "Probably needs to be uncompressed before sent to iCalender, though." | ||
}, | ||
{ | ||
"mime": "application/vnd.google-earth.kmz", | ||
"compressible": false, | ||
"text/cmd": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/vnd.dart", | ||
"text/css": { | ||
"compressible": true, | ||
@@ -571,42 +603,35 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/vnd.android.package-archive", | ||
"compressible": false, | ||
"text/csv": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/vnd.ms-xpsdocument", | ||
"compressible": false, | ||
"text/html": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/x-7z-compressed", | ||
"compressible": false, | ||
"text/javascript": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/x-deb", | ||
"compressible": false, | ||
"sources": [], | ||
"text/n3": { | ||
"compressible": true, | ||
"sources": [ | ||
"http://en.wikipedia.org/wiki/Notation3" | ||
], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/x-dvi", | ||
"compressible": false, | ||
"text/plain": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/x-font-ttf", | ||
"text/richtext": { | ||
"compressible": true, | ||
"sources": [ | ||
"http://www.phpied.com/gzip-your-font-face-files/" | ||
], | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/x-javascript", | ||
"text/tab-separated-values": { | ||
"compressible": true, | ||
@@ -616,40 +641,33 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/x-latex", | ||
"compressible": false, | ||
"text/uri-list": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/x-mpegURL", | ||
"compressible": false, | ||
"text/vcard": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/x-rar-compressed", | ||
"compressible": false, | ||
"text/x-gwt-rpc": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/x-shockwave-flash", | ||
"compressible": false, | ||
"text/x-jquery-tmpl": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/x-stuffit", | ||
"compressible": false, | ||
"text/x-markdown": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/x-tar", | ||
"compressible": false, | ||
"text/xml": { | ||
"compressible": true, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/x-www-form-urlencode", | ||
"video/mp4": { | ||
"compressible": false, | ||
@@ -659,4 +677,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "application/x-xpinstall", | ||
"video/mpeg": { | ||
"compressible": false, | ||
@@ -666,4 +683,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "audio/x-aac", | ||
"video/ogg": { | ||
"compressible": false, | ||
@@ -673,4 +689,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "audio/x-caf", | ||
"video/quicktime": { | ||
"compressible": false, | ||
@@ -680,4 +695,3 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "image/x-xcf", | ||
"video/webm": { | ||
"compressible": false, | ||
@@ -687,26 +701,24 @@ "sources": [], | ||
}, | ||
{ | ||
"mime": "text/x-gwt-rpc", | ||
"compressible": null, | ||
"video/x-flv": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "text/x-jquery-tmpl", | ||
"compressible": null, | ||
"video/x-matroska": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "text/x-markdown", | ||
"compressible": null, | ||
"video/x-ms-wmv": { | ||
"compressible": false, | ||
"sources": [], | ||
"notes": "" | ||
}, | ||
{ | ||
"mime": "application/x-pkcs1", | ||
"compressible": false, | ||
"sources": [], | ||
"x-shader/x-fragment": { | ||
"compressible": true, | ||
"sources": [ | ||
"https://bugzilla.mozilla.org/show_bug.cgi?id=715191#c2" | ||
], | ||
"notes": "" | ||
} | ||
] | ||
} |
53
test.js
@@ -6,8 +6,51 @@ var assert = require('assert') | ||
specifications.forEach(function (type) { | ||
var value = type.compressible | ||
if (typeof value !== 'boolean') return | ||
it(type.mime + ' should' + (value ? ' ' : ' not ') + 'be compressible', function () { | ||
assert.equal(compressible(type.mime), value) | ||
// None of these should be actual types so that the lookup will never include them. | ||
var example_types = [ | ||
{ type: 'something/text', should: true }, | ||
{ type: 'thingie/dart', should: true }, | ||
{ type: 'type/json', should: true }, | ||
{ type: 'ecmascript/6', should: true }, | ||
{ type: 'data/beans+xml', should: true }, | ||
{ type: 'asdf/nope', should: false }, | ||
{ type: 'cats', should: false } | ||
] | ||
var object_true = { | ||
compressible: true, | ||
sources: ["compressible.regex"], | ||
notes: "Automatically generated via regex." | ||
}, object_false = { | ||
compressible: false, | ||
sources: ["compressible.regex"], | ||
notes: "Automatically generated via regex." | ||
} | ||
describe('Testing if spec lookups are correct.', function () { | ||
for (var type in specifications) { | ||
var value = specifications[type].compressible | ||
it(type + ' should' + (value ? ' ' : ' not ') + 'be compressible', function () { | ||
assert.equal(compressible(type), value) | ||
}) | ||
} | ||
}) | ||
describe('Testing if the regex works as intended.', function () { | ||
example_types.forEach(function (example) { | ||
it(example.type + ' should' + (example.should ? ' ' : ' not ') + 'be compressible', function () { | ||
assert.equal(compressible(example.type), example.should) | ||
}) | ||
}) | ||
}) | ||
describe('Testing if getter returns the correct objects.', function () { | ||
it('All spec objects should be get-able', function () { | ||
for (var type in specifications) { | ||
assert.equal(compressible.get(type), specifications[type]) | ||
} | ||
}) | ||
example_types.forEach(function (example) { | ||
it(example.type + ' should generate a ' + (example.should ? 'true' : 'false') + ' object.', function () { | ||
assert.deepEqual(compressible.get(example.type), example.should ? object_true: object_false) | ||
}) | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
18963
730
51
1