Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

bugfix(loadAssets): Fix the problem that failing at requsting a base6… #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions src/mockWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,31 @@ const actions = {
}
}
else {
const req = new XMLHttpRequest()
req.open("GET", url, true);
req.responseType = "arraybuffer"
// load success
req.onload = () => {
actions.load_viaProto(req.response, cb, failure);
};
// load error
req.onerror = (err) => {
// Do not log to console or throw, if failure() exists
if (failure) {
failure(err);
return;
}
console.error(err);
throw err;
};
req.send()
const base64ExecResult = typeof url === "string" && /^data:(.{0,});base64,(.+)/.exec(url);
if (base64ExecResult) {
const arrayBufferSVGA = actions._base64ToArrayBuffer(base64ExecResult[2]);
actions.load_viaProto(arrayBufferSVGA, cb, failure);
}
else {
const req = new XMLHttpRequest()
req.open("GET", url, true);
req.responseType = "arraybuffer"
// load success
req.onload = () => {
actions.load_viaProto(req.response, cb, failure);
};
// load error
req.onerror = (err) => {
// Do not log to console or throw, if failure() exists
if (failure) {
failure(err);
return;
}
console.error(err);
throw err;
};
req.send()
}
}
},

Expand Down