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

@tinyhttp/content-disposition

Package Overview
Dependencies
Maintainers
0
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tinyhttp/content-disposition - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

dist/index.d.ts.map

1

dist/index.d.ts

@@ -21,1 +21,2 @@ export declare class ContentDisposition {

export declare function parse(header: string): ContentDisposition;
//# sourceMappingURL=index.d.ts.map

33

dist/index.js

@@ -7,3 +7,6 @@ const ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g;

const QUOTE_REGEXP = /([\\"])/g;
const PARAM_REGEXP = /;[\x09\x20]*([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*=[\x09\x20]*("(?:[\x20!\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\x20-\x7e])*"|[!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*/g;
const PARAM_REGEXP = (
// biome-ignore lint/suspicious/noControlCharactersInRegex: <explanation>
/;[\x09\x20]*([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*=[\x09\x20]*("(?:[\x20!\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\x20-\x7e])*"|[!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*/g
);
const TEXT_REGEXP = /^[\x20-\x7e\x80-\xff]+$/;

@@ -22,8 +25,8 @@ const TOKEN_REGEXP = /^[!#$%&'*+.0-9A-Z^_`a-z|~-]+$/;

}
const qstring = (val) => '"' + String(val).replace(QUOTE_REGEXP, "\\$1") + '"';
const pencode = (char) => "%" + String(char).charCodeAt(0).toString(16).toUpperCase();
const qstring = (val) => `"${String(val).replace(QUOTE_REGEXP, "\\$1")}"`;
const pencode = (char) => `%${String(char).charCodeAt(0).toString(16).toUpperCase()}`;
function ustring(val) {
const str = String(val);
const encoded = encodeURIComponent(str).replace(ENCODE_URL_ATTR_CHAR_REGEXP, pencode);
return "UTF-8''" + encoded;
return `UTF-8''${encoded}`;
}

@@ -43,3 +46,3 @@ const basename = (str) => str.slice(str.lastIndexOf("/") + 1);

const val = param.slice(-1) === "*" ? ustring(parameters[param]) : qstring(parameters[param]);
string += "; " + param + "=" + val;
string += `; ${param}=${val}`;
}

@@ -50,7 +53,5 @@ }

function createParams(filename, fallback) {
if (filename === void 0)
return;
if (filename === void 0) return;
const params = {};
if (fallback === void 0)
fallback = true;
if (!fallback) fallback = true;
if (typeof fallback === "string" && NON_LATIN1_REGEXP.test(fallback)) {

@@ -71,3 +72,3 @@ throw new TypeError("fallback must be ISO-8859-1 string");

}
const pdecode = (_str, hex) => String.fromCharCode(parseInt(hex, 16));
const pdecode = (_str, hex) => String.fromCharCode(Number.parseInt(hex, 16));
function contentDisposition(filename, options = {}) {

@@ -78,4 +79,3 @@ return format(new ContentDisposition(options.type || "attachment", createParams(filename, options.fallback)));

const match = EXT_VALUE_REGEXP.exec(str);
if (!match)
throw new TypeError("invalid extended field value");
if (!match) throw new TypeError("invalid extended field value");
const charset = match[1].toLowerCase();

@@ -102,4 +102,3 @@ const encoded = match[2];

let match = DISPOSITION_TYPE_REGEXP.exec(header);
if (!match)
throw new TypeError("invalid type format");
if (!match) throw new TypeError("invalid type format");
let index = match[0].length;

@@ -113,4 +112,3 @@ const type = match[1].toLowerCase();

while (match = PARAM_REGEXP.exec(header)) {
if (match.index !== index)
throw new TypeError("invalid parameter format");
if (match.index !== index) throw new TypeError("invalid parameter format");
index += match[0].length;

@@ -129,4 +127,3 @@ key = match[1].toLowerCase();

}
if (typeof params[key] === "string")
continue;
if (typeof params[key] === "string") continue;
if (value[0] === '"') {

@@ -133,0 +130,0 @@ value = value.slice(1, value.length - 1).replace(QESC_REGEXP, "$1");

{
"name": "@tinyhttp/content-disposition",
"description": "content-disposition rewrite in TypeScript",
"version": "2.2.0",
"version": "2.2.1",
"license": "MIT",

@@ -6,0 +6,0 @@ "homepage": "https://tinyhttp.v1rtl.site",

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