Skip to content

Commit

Permalink
buffer: stricter isEncoding
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
BridgeAR committed Feb 22, 2018
1 parent f8249bb commit c5aa244
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 c5aa244

Please sign in to comment.