Skip to content

Commit 6236fc2

Browse files
committed
fix: handle body with falsy values
1 parent 25a6195 commit 6236fc2

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/utils/body.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ const ParsedBodySymbol = Symbol('h3RawBody')
1414
*/
1515
export function useRawBody (req: IncomingMessage, encoding: Encoding = 'utf-8'): Encoding extends false ? Buffer : Promise<string> {
1616
// @ts-ignore
17-
if (req[RawBodySymbol]) {
17+
if (RawBodySymbol in req) {
1818
// @ts-ignore
1919
return Promise.resolve(encoding ? req[RawBodySymbol].toString(encoding) : req[RawBodySymbol])
2020
}
2121

2222
// @ts-ignore
2323
// Workaround for unenv issue https://github.com/unjs/unenv/issues/8
24-
if (req._body) {
24+
if ('_body' in req) {
2525
// @ts-ignore
2626
return Promise.resolve(req._body)
2727
}
@@ -53,7 +53,7 @@ export function useRawBody (req: IncomingMessage, encoding: Encoding = 'utf-8'):
5353
*/
5454
export async function useBody<T=any> (req: IncomingMessage): Promise<T> {
5555
// @ts-ignore
56-
if (req[ParsedBodySymbol]) {
56+
if (ParsedBodySymbol in req) {
5757
// @ts-ignore
5858
return req[ParsedBodySymbol]
5959
}

0 commit comments

Comments
 (0)