Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

type-is

Package Overview
Dependencies
Maintainers
6
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

type-is - npm Package Compare versions

Comparing version 1.6.2 to 1.6.3

8

HISTORY.md

@@ -0,1 +1,9 @@

1.6.3 / 2015-06-08
==================
* deps: mime-types@~2.1.1
- Add new mime types
* perf: reduce try block size
* perf: remove bitwise operations
1.6.2 / 2015-05-10

@@ -2,0 +10,0 @@ ==================

37

index.js

@@ -0,1 +1,7 @@

/*!
* type-is
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/

@@ -30,3 +36,3 @@ var typer = require('media-typer')

// remove parameters and normalize
var val = typenormalize(value)
var val = tryNormalizeType(value)

@@ -54,3 +60,3 @@ // no type or invalid

if (mimeMatch(normalize(type = types[i]), val)) {
return type[0] === '+' || ~type.indexOf('*')
return type[0] === '+' || type.indexOf('*') !== -1
? val

@@ -215,10 +221,27 @@ : type

* @return {string}
* @api private
* @private
*/
function typenormalize(value) {
function normalizeType(value) {
// parse the type
var type = typer.parse(value)
// remove the parameters
type.parameters = undefined
// reformat it
return typer.format(type)
}
/**
* Try to normalize a type and remove parameters.
*
* @param {string} value
* @return {string}
* @private
*/
function tryNormalizeType(value) {
try {
var type = typer.parse(value)
delete type.parameters
return typer.format(type)
return normalizeType(value)
} catch (err) {

@@ -225,0 +248,0 @@ return null

10

package.json
{
"name": "type-is",
"description": "Infer the content-type of a request.",
"version": "1.6.2",
"author": "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)",
"version": "1.6.3",
"contributors": [
"Douglas Christopher Wilson <doug@somethingdoug.com>"
"Douglas Christopher Wilson <doug@somethingdoug.com>",
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
],

@@ -13,6 +13,6 @@ "license": "MIT",

"media-typer": "0.3.0",
"mime-types": "~2.0.11"
"mime-types": "~2.1.1"
},
"devDependencies": {
"istanbul": "0.3.9",
"istanbul": "0.3.14",
"mocha": "~1.21.5"

@@ -19,0 +19,0 @@ },

@@ -66,3 +66,3 @@ # type-is

`false` will be returned if no type matches.
`false` will be returned if no type matches or the content type is invalid.

@@ -109,11 +109,11 @@ `null` will be returned if the request does not have a body.

[npm-image]: https://img.shields.io/npm/v/type-is.svg?style=flat
[npm-image]: https://img.shields.io/npm/v/type-is.svg
[npm-url]: https://npmjs.org/package/type-is
[node-version-image]: https://img.shields.io/node/v/type-is.svg?style=flat
[node-version-image]: https://img.shields.io/node/v/type-is.svg
[node-version-url]: http://nodejs.org/download/
[travis-image]: https://img.shields.io/travis/jshttp/type-is.svg?style=flat
[travis-image]: https://img.shields.io/travis/jshttp/type-is/master.svg
[travis-url]: https://travis-ci.org/jshttp/type-is
[coveralls-image]: https://img.shields.io/coveralls/jshttp/type-is.svg?style=flat
[coveralls-image]: https://img.shields.io/coveralls/jshttp/type-is/master.svg
[coveralls-url]: https://coveralls.io/r/jshttp/type-is?branch=master
[downloads-image]: https://img.shields.io/npm/dm/type-is.svg?style=flat
[downloads-image]: https://img.shields.io/npm/dm/type-is.svg
[downloads-url]: https://npmjs.org/package/type-is

Sorry, the diff of this file is not supported yet

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