File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -403,8 +403,10 @@ export class MultipartFormDataMatcher extends Serializable implements RequestMat
403403 const parsedBody = multipart . parse ( await request . body . asDecodedBuffer ( ) , boundary [ 1 ] ) ;
404404
405405 return this . matchConditions . every ( ( condition ) => {
406- const expectedContent = condition . content
407- ? Buffer . from ( condition . content )
406+ const expectedContent = typeof condition . content === 'string'
407+ ? Buffer . from ( condition . content , "utf8" )
408+ : condition . content
409+ ? Buffer . from ( condition . content )
408410 : undefined ;
409411
410412 return parsedBody . some ( ( part ) =>
Original file line number Diff line number Diff line change @@ -193,7 +193,10 @@ async function writeResponseFromCallback(
193193 // RawBody takes priority if both are set (useful for backward compat) but if not then
194194 // the body is automatically encoded to match the content-encoding header.
195195 result . rawBody = await encodeBodyBuffer (
196- Buffer . from ( result . body ) ,
196+ // Separate string case mostly required due to TS type issues:
197+ typeof result . body === 'string'
198+ ? Buffer . from ( result . body , "utf8" )
199+ : Buffer . from ( result . body ) ,
197200 result . headers ?? { }
198201 ) ;
199202 }
You can’t perform that action at this time.
0 commit comments