You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@fastify/multipart

Package Overview
Dependencies
Maintainers
19
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.7.0 to 7.7.1

28

index.js

@@ -168,15 +168,17 @@ 'use strict'

const body = {}
for (const key of Object.keys(req.body)) {
const field = req.body[key]
if (field.value !== undefined) {
body[key] = field.value
} else if (Array.isArray(field)) {
body[key] = field.map(item => {
if (item._buf !== undefined) {
return item._buf.toString()
}
return item.value
})
} else if (field._buf !== undefined) {
body[key] = field._buf.toString()
if (req.body) {
for (const key of Object.keys(req.body)) {
const field = req.body[key]
if (field.value !== undefined) {
body[key] = field.value
} else if (Array.isArray(field)) {
body[key] = field.map(item => {
if (item._buf !== undefined) {
return item._buf.toString()
}
return item.value
})
} else if (field._buf !== undefined) {
body[key] = field._buf.toString()
}
}

@@ -183,0 +185,0 @@ }

{
"name": "@fastify/multipart",
"version": "7.7.0",
"version": "7.7.1",
"description": "Multipart plugin for Fastify",

@@ -27,5 +27,5 @@ "main": "index.js",

"eslint": "^8.20.0",
"eslint-config-standard-with-typescript": "^34.0.0",
"eslint-config-standard-with-typescript": "^36.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.2.4",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-promise": "^6.0.0",

@@ -32,0 +32,0 @@ "fastify": "^4.0.0",

@@ -51,1 +51,43 @@ 'use strict'

})
test('should not break with a empty request body when attachFieldsToBody is keyValues', async function (t) {
t.plan(5)
const fastify = Fastify()
t.teardown(fastify.close.bind(fastify))
fastify.register(multipart, { attachFieldsToBody: 'keyValues' })
fastify.post('/', async function (req, reply) {
t.ok(req.isMultipart())
const files = await req.saveRequestFiles()
t.ok(Array.isArray(files))
t.equal(files.length, 0)
reply.code(200).send()
})
await fastify.listen({ port: 0 })
// request
const form = new FormData()
const opts = {
protocol: 'http:',
hostname: 'localhost',
port: fastify.server.address().port,
path: '/',
headers: form.getHeaders(),
method: 'POST'
}
const req = http.request(opts)
form.pipe(req)
const [res] = await once(req, 'response')
t.equal(res.statusCode, 200)
res.resume()
await once(res, 'end')
t.pass('res ended successfully')
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc