Large refactor to make the parser 3x faster and lenient on input. Removes the default export and renames it to create.
import { create, parse, format } from 'content-disposition';
create('filename');
parse(
'attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt',
);
format({
type: 'attachment',
parameters: {
filename: '€ rates.txt',
},
});Adds a multipart option that can be used to parse the header within multipart/form-data appropriately.
Note: The filename in create is no longer normalized with basename, ensure you are using appropriate filenames and not exposing your directory structure by using absolute paths.
Changed
- Rename exports (#123) ec3a844
- No default export, use
createexport instead
- No default export, use
- Removed
basenamefromcreate, pass a filename instead of a full path - Refactor parser to be faster and lenient (e.g. now parses unicode)
- Change filename in
createto ASCII only (#132) 3190b76 - Null object performance bump (#124) 7c7c9c0
- Remove fallback behavior from decoder (#127) 7086236
- Invalid UTF-8 is no longer supported
- Refactor project to TypeScript (#118) 4fbf7ff
Added
- Expose
formatmethod (#129) 2bb7da3 - Allow extended parsing to be disabled (#130) c6b15c8
- Add HTML multipart behavior compatibility (#131) 3d217fb