Skip to content

Commit c5aa244

Browse files
committed
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.
1 parent f8249bb commit c5aa244

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/buffer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ Buffer.compare = function compare(a, b) {
427427

428428

429429
Buffer.isEncoding = function isEncoding(encoding) {
430-
return typeof encoding === 'string' &&
430+
return typeof encoding === 'string' && encoding.length !== 0 &&
431431
normalizeEncoding(encoding) !== undefined;
432432
};
433433
Buffer[kIsEncodingSymbol] = Buffer.isEncoding;

0 commit comments

Comments
 (0)