Skip to content

Commit 452eed9

Browse files
committed
buffer: stricter isEncoding
Due to code consolidation in nodejs#7207 the isEncoding function got less strict. This commit makes sure isEncoding returns false for empty strings as before the consolidation. PR-URL: nodejs#18790 Refs: nodejs#7207 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 341770f commit 452eed9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/buffer.js

+1-1
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)