@tinyhttp/content-disposition
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -35,5 +35,3 @@ import { basename } from 'path'; | ||
} | ||
function format(obj) { | ||
const parameters = obj.parameters; | ||
const type = obj.type; | ||
function format({ parameters, type }) { | ||
if (!type || typeof type !== 'string' || !TOKEN_REGEXP.test(type)) | ||
@@ -60,4 +58,2 @@ throw new TypeError('invalid type'); | ||
fallback = true; | ||
if (typeof fallback !== 'string' && typeof fallback !== 'boolean') | ||
throw new TypeError('fallback must be a string or boolean'); | ||
if (typeof fallback === 'string' && NON_LATIN1_REGEXP.test(fallback)) | ||
@@ -87,6 +83,5 @@ throw new TypeError('fallback must be ISO-8859-1 string'); | ||
*/ | ||
function contentDisposition(filename, options) { | ||
const opts = options || {}; | ||
function contentDisposition(filename, options = {}) { | ||
// format into string | ||
return format(new ContentDisposition(opts.type || 'attachment', createParams(filename, opts.fallback))); | ||
return format(new ContentDisposition(options.type || 'attachment', createParams(filename, options.fallback))); | ||
} | ||
@@ -119,4 +114,2 @@ function decodefield(str) { | ||
function parse(string) { | ||
if (!string || typeof string !== 'string') | ||
throw new TypeError('argument string is required'); | ||
let match = DISPOSITION_TYPE_REGEXP.exec(string); | ||
@@ -123,0 +116,0 @@ if (!match) |
{ | ||
"name": "@tinyhttp/content-disposition", | ||
"description": "content-disposition rewrite in TypeScript with ESM and CommonJS targets", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"homepage": "https://tinyhttp.v1rtl.site", | ||
@@ -6,0 +6,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18271
324