🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

type-is

Package Overview
Dependencies
Maintainers
5
Versions
39
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

to
2.0.1

3

HISTORY.md

@@ -0,1 +1,4 @@

2.0.1 / 2025-03-27
==========
2.0.0 / 2024-08-31

@@ -2,0 +5,0 @@ ==========

46

index.js

@@ -119,4 +119,5 @@ /*!

*
* @param {String|Array} types...
* @return {String|false|null}
* @param {Object} req
* @param {(String|Array)} types...
* @return {(String|false|null)}
* @public

@@ -126,17 +127,8 @@ */

function typeofrequest (req, types_) {
var types = types_
// no body
if (!hasbody(req)) {
return null
}
if (!hasbody(req)) return null
// support flattened arguments
if (arguments.length > 2) {
types = new Array(arguments.length - 1)
for (var i = 0; i < types.length; i++) {
types[i] = arguments[i + 1]
}
}
var types = arguments.length > 2
? Array.prototype.slice.call(arguments, 1)
: types_
// request content type

@@ -220,5 +212,5 @@ var value = req.headers['content-type']

// validate suffix wildcard
if (expectedParts[1].substr(0, 2) === '*+') {
if (expectedParts[1].slice(0, 2) === '*+') {
return expectedParts[1].length <= actualParts[1].length + 1 &&
expectedParts[1].substr(1) === actualParts[1].substr(1 - expectedParts[1].length)
expectedParts[1].slice(1) === actualParts[1].slice(1 - expectedParts[1].length)
}

@@ -238,15 +230,10 @@

* @param {string} value
* @return {string}
* @return {(string|null)}
* @private
*/
function normalizeType (value) {
// parse the type
// Parse the type
var type = contentType.parse(value).type
if (!typer.test(type)) {
return null
}
return type
return typer.test(type) ? type : null
}

@@ -258,13 +245,8 @@

* @param {string} value
* @return {string}
* @return {(string|null)}
* @private
*/
function tryNormalizeType (value) {
if (!value) {
return null
}
try {
return normalizeType(value)
return value ? normalizeType(value) : null
} catch (err) {

@@ -271,0 +253,0 @@ return null

{
"name": "type-is",
"description": "Infer the content-type of a request.",
"version": "2.0.0",
"version": "2.0.1",
"contributors": [

@@ -6,0 +6,0 @@ "Douglas Christopher Wilson <doug@somethingdoug.com>",