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

@otterhttp/content-type

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@otterhttp/content-type - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

6

dist/index.d.ts

@@ -9,2 +9,4 @@ import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'node:http';

};
type TypeParseableObject = Request | Response;
type TypeParseable = string | TypeParseableObject;
/**

@@ -28,5 +30,5 @@ * Class to represent a content type.

*/
declare function parse(string: string | Request | Response): ContentType;
declare function parse(value: TypeParseable): ContentType;
declare function isPlainText({ type }: ContentType): boolean;
export { format, isPlainText, parse };
export { type TypeParseable, type TypeParseableObject, format, isPlainText, parse };

@@ -19,4 +19,3 @@ // src/index.ts

} else if ("headers" in obj && typeof obj.headers === "object") {
const h = obj.headers;
header = h?.["content-type"];
header = obj.headers["content-type"];
}

@@ -48,5 +47,5 @@ if (typeof header !== "string") {

}
function parse(string) {
if (!string) throw new TypeError("argument string is required");
const header = typeof string === "object" ? getContentType(string) : string;
function parse(value) {
if (!value) throw new TypeError("argument string is required");
const header = typeof value === "object" ? getContentType(value) : value;
if (typeof header !== "string") throw new TypeError("argument string is required to be a string");

@@ -60,3 +59,3 @@ let index = header.indexOf(";");

let match;
let value;
let value2;
PARAM_REGEXP.lastIndex = index;

@@ -67,7 +66,7 @@ while (match = PARAM_REGEXP.exec(header)) {

key = match[1].toLowerCase();
value = match[2];
if (value[0] === '"') {
value = value.slice(1, value.length - 1).replace(QESC_REGEXP, "$1");
value2 = match[2];
if (value2[0] === '"') {
value2 = value2.slice(1, value2.length - 1).replace(QESC_REGEXP, "$1");
}
obj.parameters[key] = value;
obj.parameters[key] = value2;
}

@@ -74,0 +73,0 @@ if (index !== header.length) throw new TypeError("invalid parameter format");

{
"name": "@otterhttp/content-type",
"description": "content-type rewrite in TypeScript",
"version": "0.2.0",
"version": "0.3.0",
"license": "LGPL-3.0-or-later",

@@ -6,0 +6,0 @@ "homepage": "https://otterhttp.lordfirespeed.dev",

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