content-disposition-attachment
Advanced tools
Comparing version 0.3.0 to 0.3.1
{ | ||
"name": "content-disposition-attachment", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "A library to parse \"attachment\"s in Content-Disposition.", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
@@ -7,4 +7,6 @@ # content-disposition-attachment | ||
## Installation | ||
## Getting started | ||
### Install via npm | ||
```sh | ||
@@ -14,4 +16,45 @@ npm install content-disposition-attachment | ||
## Getting Started | ||
#### 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' } | ||
``` | ||
### Import from CDN | ||
#### UMD | ||
```html | ||
<script src="https://unpkg.com/content-disposition-attachment@0.3"></script> | ||
<script> | ||
console.log(ContentDispositionAttachment.parse('attachment; filename="foo.html"')); | ||
// => { attachment: true, filename: 'foo.html' } | ||
</script> | ||
``` | ||
#### ESM | ||
```html | ||
<script type="module"> | ||
import { parse } from 'https://unpkg.com/content-disposition-attachment@0.3?module'; | ||
console.log(parse('attachment; filename=foo.html')); | ||
// => { attachment: true, filename: 'foo.html' } | ||
</script> | ||
``` | ||
## API references | ||
### parse | ||
@@ -31,12 +74,12 @@ | ||
parse('inline') | ||
parse('inline'); | ||
// => { attachment: false } | ||
parse('attachment; filename=foo.html; foo=bar') | ||
parse('attachment; filename=foo.html; foo=bar'); | ||
// => { attachment: true, filename: 'foo.html', foo: 'bar' } | ||
parse('attachment; foo') | ||
parse('attachment; foo'); | ||
// => ParseError: expect '=' | ||
``` | ||
You can find more examples in the [examples directory](examples/) and the [unit tests](test/). | ||
You can find more examples in the [unit tests](test/parse.js). |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
48756
83
0