Releases: octet-stream/form-data-encoder
Releases · octet-stream/form-data-encoder
2.1.2
2.1.1
2.1.0
Update
- Fix a bug with
NaNreturned asContent-Lengthvalue whenFormDataEncoderdiscovers entries without known length.
All changes: v2.0.1...v2.1.0
2.0.1
2.0.0
Breaking
- Drop CommonJS support. The package is now ESM only;
- Remove
Encoderfrom exports; - Remove deprecated
isFormDataLikehelper. UseisFormDatainstead.
Update
- Minimal required Node.js version is 14.18;
- Headers in
FormDataEncoder.headersproperty can be accessed in case-insensitive manner. TypeScript users still have correct TS typings, but only for original and lowercased keys (for exampleContent-Typeandcontent-type); FormDatainstance will be preserved in array inside ofFormDataEncoderinstance (previously it held a reference to givenFormDatainstance);- Deprecate
isFileLikehelper. UseisFileinstead; - Deprecate
FormDataEncoder.getContentLength()method. The content-length is now static value, so this method makes no sense. UseFormDataEncoder.contentLengthorFormDataEncoder.headers["content-length"]instead.
Add
- Expose
FormDataEncoderHeaderstype.
All changes: v1.7.2...v2.0.0
1.7.2
Update
- Replace negative lookbehind with replacer function in
normalizeValueutility, because it of the compatibility issues in Safari (See: #5)
All changes: v1.7.1...v1.7.2
1.7.1
1.7.0
Update
- Use only lowercased alphabetical + numeric characters in
createBoundaryfunction to improve compatibility with existentBlobimplementation as it's one of the supported targets; - In-code documentation improvements;
All changes: v1.6.0...v1.7.0
1.6.0
Add
- Add
optionsargument forFormDataEncoderconstructor; - Add support for per part
Content-Lengthheader. It turned off by default, because it is not spec-compliant extension - the web clients does not include it. UseenableAdditionalHeadersoption to enable this header:
import {Readable} from "stream"
import {FormDataEncoder} from "form-data-encoder"
import {FormData, File} from "formdata-node"
const form = new FormData()
const file = new File(["My hovercraft is full of eels"], "file.txt", {type: "text/plain"})
form.set("field", "Some field")
form.set("file", file)
// You can pass options as the second or third argument
const encoder = new FormDataEncoder(form, {enableAdditionalHeaders: true})
Readable.from(encoder).pipe(process.stdout)Outputs:
--form-data-boundary-ZrZBNwvvIVAsVl6f
Content-Disposition: form-data; name="field"
Content-Length: 10
Some field
--form-data-boundary-ZrZBNwvvIVAsVl6f
Content-Disposition: form-data; name="file"; filename="file.txt"
Content-Type: text/plain
Content-Length: 29
My hovercraft if full of eels
--form-data-boundary-ZrZBNwvvIVAsVl6f--
To find more information about additional headers per form-data part, see:
All changes: v1.5.4...v1.6.0