Skip to content

Commit

Permalink
do not modify req.raw
Browse files Browse the repository at this point in the history
  • Loading branch information
gurgunday committed Oct 8, 2023
1 parent bf18acc commit d2355e6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const InvalidJSONFieldError = createError('FST_INVALID_JSON_FIELD_ERROR', 'a req
const FileBufferNotFoundError = createError('FST_FILE_BUFFER_NOT_FOUND', 'the file buffer was not found', 500)

function setMultipart (req, payload, done) {
req.raw[kMultipart] = true
req[kMultipart] = true
done()
}

Expand Down Expand Up @@ -138,6 +138,7 @@ function fastifyMultipart (fastify, options, done) {
})

fastify.addContentTypeParser('multipart/form-data', setMultipart)
fastify.decorateRequest(kMultipart, false)
fastify.decorateRequest(kMultipartHandler, handleMultipart)

fastify.decorateRequest('parts', getMultipartIterator)
Expand All @@ -159,7 +160,7 @@ function fastifyMultipart (fastify, options, done) {
})

function isMultipart () {
return this.raw[kMultipart]
return this[kMultipart]
}

function handleMultipart (opts = {}) {
Expand Down

0 comments on commit d2355e6

Please sign in to comment.