0.0.3 • Published 9 months ago

content-disposition-parse v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

content-disposition-parse

NPM Version NPM Downloads

Parse HTTP Content-Disposition header based on this content-disposition

Installation

$ npm install content-disposition-parse

Example

const { ContentDisposition } = require('content-disposition-parse');

const result = ContentDisposition.parse('attachment; filename="example.txt"');
console.log(result);

//output result 
{ type: 'attachment', parameters: { filename: 'example.txt' } }

Usage

Specifies the disposition type, defaults to "attachment". This can also be "inline", or any other value (all values except inline are treated like attachment, but can convey additional information if both parties agree to it). The type is normalized to lower-case.

Parse a Content-Disposition header string. This automatically handles extended ("Unicode") parameters by decoding them and providing them under the standard parameter name. This will return an object with the following properties (examples are shown for the string 'attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt'):

  • type: The disposition type (always lower case). Example: 'attachment'

  • parameters: An object of the parameters in the disposition (name of parameter always lower case and extended versions replace non-extended versions). Example: {filename: "€ rates.txt"}

References

License

MIT

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago

1.0.1

11 years ago

1.0.0

11 years ago