pax_global_header00006660000000000000000000000064124121425300014504gustar00rootroot0000000000000052 comment=d47ae682792b87d92986611006a3c8eb971932be compressible-2.0.1/000077500000000000000000000000001241214253000141735ustar00rootroot00000000000000compressible-2.0.1/.gitignore000066400000000000000000000002271241214253000161640ustar00rootroot00000000000000# OS X .DS_Store* Icon? ._* # Windows Thumbs.db ehthumbs.db Desktop.ini # Linux .directory *~ # npm node_modules *.log *.gz # Coveralls coverage compressible-2.0.1/.travis.yml000066400000000000000000000002521241214253000163030ustar00rootroot00000000000000node_js: - "0.8" - "0.10" - "0.11" language: node_js script: "npm run-script test-travis" after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls" compressible-2.0.1/HISTORY.md000066400000000000000000000004501241214253000156550ustar00rootroot000000000000002.0.1 / 2014-09-28 ================== * deps: mime-db@1.x - Add new mime types - Add additional compressible - Update charsets 2.0.0 / 2014-09-02 ================== * use mime-db * remove .get() * specifications are now private * regex is now private * stricter regex compressible-2.0.1/LICENSE000066400000000000000000000022121241214253000151750ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2013 Jonathan Ong me@jongleberry.com Copyright (c) 2014 Jeremiah Senkpiel fishrock123@rocketmail.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. compressible-2.0.1/README.md000066400000000000000000000024261241214253000154560ustar00rootroot00000000000000# compressible [![NPM Version][npm-image]][npm-url] [![NPM Downloads][downloads-image]][downloads-url] [![Node.js Version][node-version-image]][node-version-url] [![Build Status][travis-image]][travis-url] [![Test Coverage][coveralls-image]][coveralls-url] Compressible `Content-Type` / `mime` checking. ### Installation ```bash $ npm install compressible ``` ## API ### compressible(type) Checks if the given content-type is compressible. ```js var compressible = require('compressible') compressible('text/html') // => true compressible('image/png') // => false ``` ## [MIT Licensed](LICENSE) [npm-image]: https://img.shields.io/npm/v/compressible.svg?style=flat [npm-url]: https://npmjs.org/package/compressible [node-version-image]: https://img.shields.io/badge/node.js-%3E%3D_0.6-brightgreen.svg?style=flat [node-version-url]: http://nodejs.org/download/ [travis-image]: https://img.shields.io/travis/jshttp/compressible.svg?style=flat [travis-url]: https://travis-ci.org/jshttp/compressible [coveralls-image]: https://img.shields.io/coveralls/jshttp/compressible.svg?style=flat [coveralls-url]: https://coveralls.io/r/jshttp/compressible?branch=master [downloads-image]: https://img.shields.io/npm/dm/compressible.svg?style=flat [downloads-url]: https://npmjs.org/package/compressible compressible-2.0.1/index.js000066400000000000000000000013441241214253000156420ustar00rootroot00000000000000/*! * compressible * Copyright(c) 2014 Jeremiah Senkpiel * MIT Licensed */ /** * Module dependencies. */ var db = require('mime-db') /** * Module exports. */ module.exports = compressible /** * Checks if a type is compressible. * * @param {string} type * @return {Boolean} compressible */ function compressible(type) { if (!type || typeof type !== "string") return false // Strip charset var i = type.indexOf(';') if (~i) type = type.slice(0, i) // handle types that have capitals or excess space type = type.trim().toLowerCase() // attempt to look up from database; fallback to regex if not found var mime = db[type] return mime ? mime.compressible : /^text\/|\+json$|\+text$|\+xml$/.test(type) } compressible-2.0.1/package.json000066400000000000000000000016401241214253000164620ustar00rootroot00000000000000{ "name": "compressible", "description": "Compressible Content-Type / mime checking", "version": "2.0.1", "contributors": [ "Jonathan Ong (http://jongleberry.com)", "Jeremiah Senkpiel (https://searchbeam.jit.su)" ], "license": "MIT", "repository": "jshttp/compressible", "keywords": [ "compress", "gzip", "mime", "content-type" ], "dependencies": { "mime-db": "1.x" }, "devDependencies": { "istanbul": "0", "mocha": "~1.20.1" }, "engines": { "node": ">= 0.6.0" }, "files": [ "LICENSE", "index.js" ], "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot -check-leaks", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot --check-leaks" } } compressible-2.0.1/test/000077500000000000000000000000001241214253000151525ustar00rootroot00000000000000compressible-2.0.1/test/test.js000066400000000000000000000045101241214253000164670ustar00rootroot00000000000000var assert = require('assert') var db = require('mime-db') var compressible = require('../') // None of these should be actual types so that the lookup will never include them. var example_types = [ { type: 'text/penguins', should: true }, { type: 'something/text', should: false }, { type: 'something/frog+TEXT', should: true }, { type: 'type/json;askjkl+json', should: false }, { type: 'type/+json', should: true }, { type: 'data/beans+xml ; charset="utf-8"', should: true }, { type: 'can/worms+xml;blaaaah', should: true }, { type: 'data/xml', should: false }, { type: 'asdf/nope', should: false }, { type: 'cats', should: false } ] var invalid_types = [ undefined, null, 0, 1, false, true ] describe('Testing if spec lookups are correct.', function () { it('All DB `compressible` types should reflect in compressible', function () { for (var type in db) { var value = db[type].compressible 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 charsets are handled correctly.', function () { it('Charsets should be stripped off without issue', function () { for (var type in db) { var value = db[type].compressible assert.equal(compressible(type + '; charset=utf-8'), value) } }) }) describe('Ensuring invalid types do not cause errors.', function () { it('No arguments should return false without error', function () { assert.equal(compressible(), false) }) invalid_types.forEach(function (invalid) { it(invalid + ' should return false without error', function () { assert.doesNotThrow(function () { assert.equal(compressible(invalid), false) }) }) }) }) describe('Ensuring types are always stripped correctly.', function () { it('Uppercase types should work', function () { assert.equal(compressible('TEXT/HTML'), true) assert.equal(compressible('TEXT/plain; charset="utf-8"'), true) }) it('White-spaced types should work', function () { assert.equal(compressible('application/json ; charset="utf-8"'), true) }) })