Skip to content

Commit

Permalink
buffer: stricter isEncoding
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
BridgeAR committed Mar 2, 2018
1 parent 341770f commit 452eed9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 452eed9

Please sign in to comment.