Skip to content

Commit 898d423

Browse files
mscdexFishrock123
authored andcommitted
string_decoder: don't cache Buffer.isEncoding
Some modules are monkey-patching Buffer.isEncoding, so without this they cannot do that. Fixes: #1547 PR-URL: #1548 PORT-PR-URL: #1560 PORT-FROM: v2.x / 0fa6c4a Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 65dd10e commit 898d423

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/string_decoder.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22

3-
const isEncoding = Buffer.isEncoding;
4-
53
function assertEncoding(encoding) {
6-
if (encoding && !isEncoding(encoding)) {
4+
// Do not cache `Buffer.isEncoding`, some modules monkey-patch it to support
5+
// additional encodings
6+
if (encoding && !Buffer.isEncoding(encoding)) {
77
throw new Error('Unknown encoding: ' + encoding);
88
}
99
}

0 commit comments

Comments
 (0)