Socket
Socket
Sign inDemoInstall

@tinyhttp/type-is

Package Overview
Dependencies
Maintainers
0
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tinyhttp/type-is - npm Package Compare versions

Comparing version 2.2.2 to 2.2.3

vite.config.ts

27

dist/index.js

@@ -9,4 +9,3 @@ import * as typer from "@tinyhttp/content-type";

function tryNormalizeType(value) {
if (!value)
return null;
if (!value) return null;
try {

@@ -19,19 +18,14 @@ return normalizeType(value);

function mimeMatch(expected, actual) {
if (expected === false)
return false;
if (expected === false) return false;
const actualParts = actual.split("/");
const expectedParts = expected.split("/");
if (actualParts.length !== 2 || expectedParts.length !== 2)
return false;
if (expectedParts[0] !== "*" && expectedParts[0] !== actualParts[0])
return false;
if (actualParts.length !== 2 || expectedParts.length !== 2) return false;
if (expectedParts[0] !== "*" && expectedParts[0] !== actualParts[0]) return false;
if (expectedParts[1].slice(0, 2) === "*+")
return expectedParts[1].length <= actualParts[1].length + 1 && expectedParts[1].slice(1) === actualParts[1].slice(1 - expectedParts[1].length);
if (expectedParts[1] !== "*" && expectedParts[1] !== actualParts[1])
return false;
if (expectedParts[1] !== "*" && expectedParts[1] !== actualParts[1]) return false;
return true;
}
function normalize(type) {
if (typeof type !== "string")
return false;
if (typeof type !== "string") return false;
switch (type) {

@@ -43,4 +37,3 @@ case "urlencoded":

}
if (type[0] === "+")
return "*/*" + type;
if (type[0] === "+") return `*/*${type}`;
return type.indexOf("/") === -1 ? mime.getType(type) : type;

@@ -51,6 +44,4 @@ }

const val = tryNormalizeType(value);
if (!val)
return false;
if (!types || !types.length)
return val;
if (!val) return false;
if (!types || !types.length) return val;
let type;

@@ -57,0 +48,0 @@ for (i = 0; i < types.length; i++) {

{
"name": "@tinyhttp/type-is",
"version": "2.2.2",
"version": "2.2.3",
"type": "module",

@@ -34,5 +34,2 @@ "description": "TypeScript rewrite of type-is with CJS and ESM targets",

},
"files": [
"dist"
],
"scripts": {

@@ -39,0 +36,0 @@ "dev": "vite",

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