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 <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
  • Loading branch information
BridgeAR authored and MayaLekova committed May 8, 2018
1 parent b454cba commit ad161a2
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 ad161a2

Please sign in to comment.