From 24dbb17fa70289a3b2eed1585f601274d741369d Mon Sep 17 00:00:00 2001 From: tsctx <91457664+tsctx@users.noreply.github.com> Date: Fri, 3 May 2024 07:20:11 +0900 Subject: [PATCH] Apply suggestions from code review --- lib/core/util.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/core/util.js b/lib/core/util.js index 76714f61d32..2bad24df2f6 100644 --- a/lib/core/util.js +++ b/lib/core/util.js @@ -212,7 +212,7 @@ function bodyLength (body) { : null } else if (isBlobLike(body)) { return body.size != null ? body.size : null - } else if (Buffer.isBuffer(body)) { + } else if (isBuffer(body)) { return body.byteLength } @@ -341,10 +341,12 @@ function parseRawHeaders (headers) { return ret } + function isBuffer (buffer) { // See, https://github.com/mcollina/undici/pull/319 return buffer instanceof Uint8Array || Buffer.isBuffer(buffer) } + function validateHandler (handler, method, upgrade) { if (!handler || typeof handler !== 'object') { throw new InvalidArgumentError('handler must be an object')