summaryrefslogtreecommitdiff
path: root/cli/js/web/blob.ts
diff options
context:
space:
mode:
authorcrowlKats <13135287+crowlKats@users.noreply.github.com>2020-03-31 20:42:18 +0200
committerGitHub <noreply@github.com>2020-03-31 14:42:18 -0400
commit7b675a332ca606e6192057da5635170c3dc7eb9a (patch)
tree3f6f57448fb700f207c91fc1860b1f9bf220d904 /cli/js/web/blob.ts
parentd4d0b5d90c8abc5867a389129ee185b2c1cf0f0f (diff)
fix: invalid blob type (#4536)
Diffstat (limited to 'cli/js/web/blob.ts')
-rw-r--r--cli/js/web/blob.ts25
1 files changed, 12 insertions, 13 deletions
diff --git a/cli/js/web/blob.ts b/cli/js/web/blob.ts
index 5309ddaf4..c4e4674ab 100644
--- a/cli/js/web/blob.ts
+++ b/cli/js/web/blob.ts
@@ -139,24 +139,23 @@ export class DenoBlob implements domTypes.Blob {
}
const { ending = "transparent", type = "" } = options ?? {};
- if (!containsOnlyASCII(type)) {
- const errMsg = "The 'type' property must consist of ASCII characters.";
- throw new SyntaxError(errMsg);
- }
-
- const bytes = processBlobParts(blobParts!, { ending, type });
// Normalize options.type.
let normalizedType = type;
- if (type.length) {
- for (let i = 0; i < type.length; ++i) {
- const char = type[i];
- if (char < "\u0020" || char > "\u007E") {
- normalizedType = "";
- break;
+ if (!containsOnlyASCII(type)) {
+ normalizedType = "";
+ } else {
+ if (type.length) {
+ for (let i = 0; i < type.length; ++i) {
+ const char = type[i];
+ if (char < "\u0020" || char > "\u007E") {
+ normalizedType = "";
+ break;
+ }
}
+ normalizedType = type.toLowerCase();
}
- normalizedType = type.toLowerCase();
}
+ const bytes = processBlobParts(blobParts!, { ending, type });
// Set Blob object's properties.
this[bytesSymbol] = bytes;
this.size = bytes.byteLength;