A library to parse "attachment"s in Content-Disposition.
npm install content-disposition-attachment
> A library to parse "attachment"s in Content-Disposition.
``sh`
npm install content-disposition-attachment
#### ESM
`js
import { parse } from 'content-disposition-attachment';
console.log(parse('attachment; filename=foo.html'));
// => { attachment: true, filename: 'foo.html' }
`
#### CommonJS
`js
const { parse } = require('content-disposition-attachment');
console.log(parse('attachment; filename=foo.html'));
// => { attachment: true, filename: 'foo.html' }
`
#### UMD
`html`
#### ESM
`html`
> Parse a Content-Disposition.
If Content-Disposition is not "attachment", it returns { attachment: false };{ attachment: true }
otherwise, it returns along with parsed parameters.
If errors occur when parsing parameters, a ParseError will be thrown.
Examples
`js
import { parse } from 'content-disposition-attachment';
parse('inline');
// => { attachment: false }
parse('attachment; filename=foo.html; foo=bar');
// => { attachment: true, filename: 'foo.html', foo: 'bar' }
parse('attachment; foo');
// => ParseError: expect '='
``
You can find more examples in the unit tests.