From c5aa244f715023fd4572b2e1930d920dc95f86b0 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Thu, 15 Feb 2018 03:26:17 +0100 Subject: [PATCH] buffer: stricter isEncoding Due to a consolidation the isEncoding function got less strict in version 5.x.x. This commit makes sure we do not return `true` for empty strings. --- lib/buffer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/buffer.js b/lib/buffer.js index 68cebedcc97ef4..0aa9e2001bd9d7 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -427,7 +427,7 @@ Buffer.compare = function compare(a, b) { Buffer.isEncoding = function isEncoding(encoding) { - return typeof encoding === 'string' && + return typeof encoding === 'string' && encoding.length !== 0 && normalizeEncoding(encoding) !== undefined; }; Buffer[kIsEncodingSymbol] = Buffer.isEncoding;