mirror of
https://github.com/denoland/deno.git
synced 2024-12-26 17:19:06 -05:00
fix(op_crates/web): TextEncoder should return error message with original input (#8005)
This commit is contained in:
parent
d9ae74019e
commit
9cf06f76fd
3 changed files with 6 additions and 6 deletions
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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.`,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue