mscdex / busboy

A streaming parser for HTML form data for node.js
MIT License
2.84k stars 213 forks source link

Typings for field name #350

Open topd5 opened 9 months ago

topd5 commented 9 months ago

Hi! @types/busboy has this typing:

file: (name: string, stream: Readable, info: FileInfo) => void;

But if field name is not set, then it comes as undefined, not as string in this callback 4busboy

HTTP example:

> POST /api/files/upload HTTP/1.1
> Host: 127.0.0.1:7100
> Cookie: user_token=del
> Content-Type: multipart/form-data; boundary=X-INSOMNIA-BOUNDARY
> User-Agent: insomnia/2023.5.8
> Accept: */*
> Content-Length: 215

| --X-INSOMNIA-BOUNDARY
| Content-Disposition: form-data; name="xxx"
| blah
| --X-INSOMNIA-BOUNDARY
| Content-Disposition: form-data; name=""; filename="1.txt"
| Content-Type: text/plain
| 555
| --X-INSOMNIA-BOUNDARY--
    bb.on('file', (name, file, info) => {
      console.log('name', name);
      console.log(typeof name); // undefined
mscdex commented 9 months ago

I don't maintain typings for any of my projects, so you would need to contact whoever is maintaining those for busboy.