From 9cf06f76fdeb4b8cff4a47e269984d3b9a64a9be Mon Sep 17 00:00:00 2001 From: aca Date: Tue, 20 Oct 2020 20:47:38 +0900 Subject: [PATCH] fix(op_crates/web): TextEncoder should return error message with original input (#8005) --- cli/tests/unit/text_encoding_test.ts | 4 ++-- op_crates/web/08_text_encoding.js | 4 ++-- op_crates/web/text_encoding_test.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/tests/unit/text_encoding_test.ts b/cli/tests/unit/text_encoding_test.ts index 6a9274d028..4c5606a4f0 100644 --- a/cli/tests/unit/text_encoding_test.ts +++ b/cli/tests/unit/text_encoding_test.ts @@ -104,10 +104,10 @@ unitTest(function textDecoderASCII(): void { unitTest(function textDecoderErrorEncoding(): void { let didThrow = false; try { - new TextDecoder("foo"); + new TextDecoder("Foo"); } catch (e) { didThrow = true; - assertEquals(e.message, "The encoding label provided ('foo') is invalid."); + assertEquals(e.message, "The encoding label provided ('Foo') is invalid."); } assert(didThrow); }); diff --git a/op_crates/web/08_text_encoding.js b/op_crates/web/08_text_encoding.js index 5a84ea8a40..d933197580 100644 --- a/op_crates/web/08_text_encoding.js +++ b/op_crates/web/08_text_encoding.js @@ -973,8 +973,8 @@ if (options.fatal) { this.fatal = true; } - label = String(label).trim().toLowerCase(); - const encoding = encodings.get(label); + const _label = String(label).trim().toLowerCase(); + const encoding = encodings.get(_label); if (!encoding) { throw new RangeError( `The encoding label provided ('${label}') is invalid.`, diff --git a/op_crates/web/text_encoding_test.js b/op_crates/web/text_encoding_test.js index 7f6774ed47..9a4bb492b6 100644 --- a/op_crates/web/text_encoding_test.js +++ b/op_crates/web/text_encoding_test.js @@ -163,10 +163,10 @@ function textDecoderASCII() { function textDecoderErrorEncoding() { let didThrow = false; try { - new TextDecoder("foo"); + new TextDecoder("Foo"); } catch (e) { didThrow = true; - assert(e.message === "The encoding label provided ('foo') is invalid."); + assert(e.message === "The encoding label provided ('Foo') is invalid."); } assert(didThrow); }