Socket
Socket
Sign inDemoInstall

compressible

Package Overview
Dependencies
Maintainers
7
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compressible - npm Package Compare versions

Comparing version 1.1.1 to 2.0.0

LICENSE

51

index.js

@@ -1,32 +0,39 @@

module.exports = compressible
/*!
* compressible
* Copyright(c) 2014 Jeremiah Senkpiel
* MIT Licensed
*/
compressible.specs =
compressible.specifications = require('./specifications.json')
/**
* Module dependencies.
*/
compressible.regex =
compressible.regexp = /json|text|xml/
var db = require('mime-db')
compressible.get = get
/**
* 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)
var spec = compressible.specs[type.toLowerCase().trim()]
return spec ? spec.compressible : compressible.regex.test(type)
}
function get(type) {
if (!type || typeof type !== "string") return {
compressible: false,
notes: "Invalid type."
}
var i = type.indexOf(';')
if (~i) type = type.slice(0, i)
var spec = compressible.specs[type.toLowerCase().trim()]
return spec ? spec : {
compressible: compressible.regex.test(type),
sources: ["compressible.regex"],
notes: "Automatically generated via regex."
}
// 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)
}
{
"name": "compressible",
"description": "Compressible Content-Type / mime checking",
"version": "1.1.1",
"author": {
"name": "Jonathan Ong",
"email": "me@jongleberry.com",
"url": "http://jongleberry.com",
"twitter": "https://twitter.com/jongleberry"
},
"contributors": [{
"name": "Jeremiah Senkpiel",
"email": "fishrock123@rocketmail.com",
"url": "https://searchbeam.jit.su",
"twitter": "https://twitter.com/fishrock123"
}],
"version": "2.0.0",
"contributors": [
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)",
"Jeremiah Senkpiel <fishrock123@rocketmail.com> (https://searchbeam.jit.su)"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/expressjs/compressible.git"
},
"bugs": {
"mail": "me@jongleberry.com",
"url": "https://github.com/expressjs/compressible/issues"
},
"repository": "jshttp/compressible",
"keywords": [

@@ -32,8 +17,21 @@ "compress",

],
"dependencies": {
"mime-db": "~1.0.1"
},
"devDependencies": {
"istanbul": "0",
"mocha": "~1.20.1"
},
"engines": {
"node": ">= 0.6.0"
},
"files": [
"LICENSE",
"index.js"
],
"scripts": {
"test": "mocha --reporter spec test/"
"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
[![Build Status](https://travis-ci.org/expressjs/compressible.svg?branch=master)](https://travis-ci.org/expressjs/compressible)
[![NPM Version](https://badge.fury.io/js/compressible.svg)](https://badge.fury.io/js/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.
```sh
### Installation
```bash
$ npm install compressible

@@ -16,4 +21,7 @@ ```

Checks if the given content-type is compressible.
```js
var compressible = require('compressible')
compressible('text/html') // => true

@@ -23,38 +31,13 @@ compressible('image/png') // => false

### compressible.get(type)
## [MIT Licensed](LICENSE)
Returns the specifications object associated with the given `Content-Type`.
Generates an object using the regex if none is found.
### compressible.specs
Exports `specifications.json`.
### compressible.regex
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.
## License
The MIT License (MIT)
Copyright (c) 2013 Jonathan Ong me@jongleberry.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.
[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
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc