Aktueller Stand

This commit is contained in:
2026-01-22 19:05:45 +01:00
parent 85dee61a4d
commit e280e4eadb
1967 changed files with 397327 additions and 74093 deletions

View File

@@ -1,3 +1,15 @@
1.0.1 / 2025-11-18
=================
* Updated `engines` field to Node@18 or higher (fixed reference, see 1.0.0)
* Remove dependency `safe-buffer`
1.0.0 / 2024-08-31
==================
* drop node <18
* allow utf8 as alias for utf-8
0.5.4 / 2021-12-10
==================

View File

@@ -17,7 +17,7 @@ $ npm install content-disposition
## API
```js
var contentDisposition = require('content-disposition')
const contentDisposition = require('content-disposition')
```
### contentDisposition(filename, options)
@@ -67,7 +67,7 @@ it). The type is normalized to lower-case.
### contentDisposition.parse(string)
```js
var disposition = contentDisposition.parse('attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt')
const disposition = contentDisposition.parse('attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt')
```
Parse a `Content-Disposition` header string. This automatically handles extended
@@ -86,13 +86,13 @@ are shown for the string `'attachment; filename="EURO rates.txt"; filename*=UTF-
### Send a file for download
```js
var contentDisposition = require('content-disposition')
var destroy = require('destroy')
var fs = require('fs')
var http = require('http')
var onFinished = require('on-finished')
const contentDisposition = require('content-disposition')
const destroy = require('destroy')
const fs = require('fs')
const http = require('http')
const onFinished = require('on-finished')
var filePath = '/path/to/public/plans.pdf'
const filePath = '/path/to/public/plans.pdf'
http.createServer(function onRequest (req, res) {
// set headers
@@ -100,7 +100,7 @@ http.createServer(function onRequest (req, res) {
res.setHeader('Content-Disposition', contentDisposition(filePath))
// send file
var stream = fs.createReadStream(filePath)
const stream = fs.createReadStream(filePath)
stream.pipe(res)
onFinished(res, function () {
destroy(stream)
@@ -130,13 +130,13 @@ $ npm test
[MIT](LICENSE)
[npm-image]: https://img.shields.io/npm/v/content-disposition.svg
[npm-image]: https://img.shields.io/npm/v/content-disposition
[npm-url]: https://npmjs.org/package/content-disposition
[node-version-image]: https://img.shields.io/node/v/content-disposition.svg
[node-version-image]: https://img.shields.io/node/v/content-disposition
[node-version-url]: https://nodejs.org/en/download
[coveralls-image]: https://img.shields.io/coveralls/jshttp/content-disposition.svg
[coveralls-image]: https://img.shields.io/coverallsCoverage/github/jshttp/content-disposition
[coveralls-url]: https://coveralls.io/r/jshttp/content-disposition?branch=master
[downloads-image]: https://img.shields.io/npm/dm/content-disposition.svg
[downloads-image]: https://img.shields.io/npm/dm/content-disposition
[downloads-url]: https://npmjs.org/package/content-disposition
[github-actions-ci-image]: https://img.shields.io/github/workflow/status/jshttp/content-disposition/ci/master?label=ci
[github-actions-ci-url]: https://github.com/jshttp/content-disposition?query=workflow%3Aci
[github-actions-ci-image]: https://img.shields.io/github/actions/workflow/status/jshttp/content-disposition/ci.yml
[github-actions-ci-url]: https://github.com/jshttp/content-disposition/actions/workflows/ci.yml

View File

@@ -20,7 +20,6 @@ module.exports.parse = parse
*/
var basename = require('path').basename
var Buffer = require('safe-buffer').Buffer
/**
* RegExp to match non attr-char, *after* encodeURIComponent (i.e. not including "%")
@@ -243,7 +242,7 @@ function format (obj) {
for (var i = 0; i < params.length; i++) {
param = params[i]
var val = param.substr(-1) === '*'
var val = param.slice(-1) === '*'
? ustring(parameters[param])
: qstring(parameters[param])
@@ -281,6 +280,7 @@ function decodefield (str) {
value = getlatin1(binary)
break
case 'utf-8':
case 'utf8':
value = Buffer.from(binary, 'binary').toString('utf8')
break
default:
@@ -332,7 +332,7 @@ function parse (string) {
var value
// calculate index to start at
index = PARAM_REGEXP.lastIndex = match[0].substr(-1) === ';'
index = PARAM_REGEXP.lastIndex = match[0].slice(-1) === ';'
? index - 1
: index
@@ -369,7 +369,7 @@ function parse (string) {
if (value[0] === '"') {
// remove quotes and escapes
value = value
.substr(1, value.length - 2)
.slice(1, -1)
.replace(QESC_REGEXP, '$1')
}

View File

@@ -1,7 +1,7 @@
{
"name": "content-disposition",
"description": "Create and parse Content-Disposition header",
"version": "0.5.4",
"version": "1.0.1",
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
"license": "MIT",
"keywords": [
@@ -11,20 +11,19 @@
"res"
],
"repository": "jshttp/content-disposition",
"dependencies": {
"safe-buffer": "5.2.1"
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
},
"devDependencies": {
"deep-equal": "1.0.1",
"c8": "^10.1.2",
"eslint": "7.32.0",
"eslint-config-standard": "13.0.1",
"eslint-plugin-import": "2.25.3",
"eslint-plugin-markdown": "2.2.1",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "5.2.0",
"eslint-plugin-standard": "4.1.0",
"istanbul": "0.4.5",
"mocha": "9.1.3"
"eslint-plugin-standard": "4.1.0"
},
"files": [
"LICENSE",
@@ -33,12 +32,12 @@
"index.js"
],
"engines": {
"node": ">= 0.6"
"node": ">=18"
},
"scripts": {
"lint": "eslint .",
"test": "mocha --reporter spec --bail --check-leaks test/",
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/"
"test": "node --test --test-reporter spec",
"test-ci": "c8 --reporter=lcovonly --reporter=text npm test",
"test-cov": "c8 --reporter=html --reporter=text npm test"
}
}