summaryrefslogtreecommitdiff
path: root/lib/buffer.js
diff options
context:
space:
mode:
authorBrian White <mscdex@mscdex.net>2017-04-16 03:42:22 -0400
committerJames M Snell <jasnell@gmail.com>2017-04-18 08:47:11 -0700
commit7cd0d4f644e304d4c8239dca532ca4de50d981ba (patch)
treeed741fed3834c4ec941841538c6999bbc9f9f351 /lib/buffer.js
parent2519757b800a21c6b93490372841bc58307c46b7 (diff)
downloadandroid-node-v8-7cd0d4f644e304d4c8239dca532ca4de50d981ba.tar.gz
android-node-v8-7cd0d4f644e304d4c8239dca532ca4de50d981ba.tar.bz2
android-node-v8-7cd0d4f644e304d4c8239dca532ca4de50d981ba.zip
buffer: fix backwards incompatibility
4a86803f6 introduced a backwards incompatibility by accident and was not caught due to an existing test that wasn't strict enough. This commit fixes both the backwards incompatibility and the test. PR-URL: https://github.com/nodejs/node/pull/12439 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/buffer.js')
-rw-r--r--lib/buffer.js5
1 files changed, 1 insertions, 4 deletions
diff --git a/lib/buffer.js b/lib/buffer.js
index 87bdfd2d95..5450861d04 100644
--- a/lib/buffer.js
+++ b/lib/buffer.js
@@ -456,10 +456,7 @@ function byteLength(string, encoding) {
return len >>> 1;
break;
}
- if (mustMatch)
- throw new TypeError('Unknown encoding: ' + encoding);
- else
- return binding.byteLengthUtf8(string);
+ return (mustMatch ? -1 : binding.byteLengthUtf8(string));
}
Buffer.byteLength = byteLength;