diff --git a/package.json b/package.json index b4261a92..35babc47 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "istanbul": "^0.4.5", "mocha": "^5.0.0", "sinon": "^4.3.0", - "text-encoder-lite": "^1.0.1", + "text-encoding-utf-8": "^1.0.2", "whatwg-fetch": "^2.0.3" }, "dependencies": { diff --git a/src/packet/literal.js b/src/packet/literal.js index 5ba46026..f1e2b26c 100644 --- a/src/packet/literal.js +++ b/src/packet/literal.js @@ -65,7 +65,7 @@ Literal.prototype.setText = function(text, format='utf8') { Literal.prototype.getText = function(clone=false) { if (this.text === null || util.isStream(this.text)) { // Assume that this.text has been read let lastChar = ''; - const decoder = new TextDecoder('utf8'); + const decoder = new TextDecoder('utf-8'); // eslint-disable-next-line no-inner-declarations function process(value, lastChunk=false) { // decode UTF8 diff --git a/src/polyfills.js b/src/polyfills.js index 502482ed..6b462083 100644 --- a/src/polyfills.js +++ b/src/polyfills.js @@ -20,6 +20,9 @@ if (typeof window !== 'undefined') { if (typeof Array.prototype.find === 'undefined') { require('core-js/fn/array/find'); } + if (typeof Array.prototype.includes === 'undefined') { + require('core-js/fn/array/includes'); + } if (typeof Array.from === 'undefined') { require('core-js/fn/array/from'); } @@ -48,5 +51,5 @@ if (typeof TextDecoder === 'undefined') { global.TextDecoder = util.getNodeTextDecoder(); } if (typeof TextDecoder === 'undefined') { - global.TextDecoder = require('text-encoder-lite'); + global.TextDecoder = require('text-encoding-utf-8').TextDecoder; } diff --git a/src/stream.js b/src/stream.js index c0d23c5d..5f099168 100644 --- a/src/stream.js +++ b/src/stream.js @@ -361,7 +361,7 @@ function slice(input, begin=0, end=Infinity) { if (input[externalBuffer]) { input = util.concat(input[externalBuffer].concat([input])); } - if (util.isUint8Array(input)) { + if (util.isUint8Array(input) && !util.isIE11) { // IE11 subarray is buggy return input.subarray(begin, end); } return input.slice(begin, end); diff --git a/src/util.js b/src/util.js index 50175cfe..8421344c 100644 --- a/src/util.js +++ b/src/util.js @@ -34,6 +34,8 @@ import stream from './stream'; const isIE11 = typeof navigator !== 'undefined' && !!navigator.userAgent.match(/Trident\/7\.0.*rv:([0-9.]+).*\).*Gecko$/); export default { + isIE11, + isString: function(data) { return typeof data === 'string' || String.prototype.isPrototypeOf(data); },