Permalink
Browse files

buffer: stricter isEncoding

Due to code consolidation in #7207
the isEncoding function got less strict. This commit makes sure
isEncoding returns false for empty strings as before the consolidation.

PR-URL: #18790
Refs: #7207
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information...
BridgeAR committed Feb 15, 2018
1 parent 341770f commit 452eed956ef451965344cf29f61e2ab434cea9df
Showing with 1 addition and 1 deletion.
  1. +1 −1 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;

0 comments on commit 452eed9

Please sign in to comment.