diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/iconv-lite/lib/index.js | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) |
update packages
Diffstat (limited to 'node_modules/iconv-lite/lib/index.js')
-rw-r--r-- | node_modules/iconv-lite/lib/index.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/node_modules/iconv-lite/lib/index.js b/node_modules/iconv-lite/lib/index.js index 9a5247212..5391919ca 100644 --- a/node_modules/iconv-lite/lib/index.js +++ b/node_modules/iconv-lite/lib/index.js @@ -2,7 +2,7 @@ // Some environments don't have global Buffer (e.g. React Native). // Solution would be installing npm modules "buffer" and "stream" explicitly. -var Buffer = require("buffer").Buffer; +var Buffer = require("safer-buffer").Buffer; var bomHandling = require("./bom-handling"), iconv = module.exports; @@ -34,7 +34,7 @@ iconv.decode = function decode(buf, encoding, options) { iconv.skipDecodeWarning = true; } - buf = new Buffer("" + (buf || ""), "binary"); // Ensure buffer. + buf = Buffer.from("" + (buf || ""), "binary"); // Ensure buffer. } var decoder = iconv.getDecoder(encoding, options); @@ -65,7 +65,7 @@ iconv.getCodec = function getCodec(encoding) { iconv.encodings = require("../encodings"); // Lazy load all encoding definitions. // Canonicalize encoding name: strip all non-alphanumeric chars and appended year. - var enc = (''+encoding).toLowerCase().replace(/[^0-9a-z]|:\d{4}$/g, ""); + var enc = iconv._canonicalizeEncoding(encoding); // Traverse iconv.encodings to find actual codec. var codecOptions = {}; @@ -108,6 +108,11 @@ iconv.getCodec = function getCodec(encoding) { } } +iconv._canonicalizeEncoding = function(encoding) { + // Canonicalize encoding name: strip all non-alphanumeric chars and appended year. + return (''+encoding).toLowerCase().replace(/:\d{4}$|[^0-9a-z]/g, ""); +} + iconv.getEncoder = function getEncoder(encoding, options) { var codec = iconv.getCodec(encoding), encoder = new codec.encoder(options, codec); |