Better project ID parsing

This commit is contained in:
Thomas Weber committed 2021-06-24 14:09:00 -05:00
1 parent 3dd5390940
commit d76f613133
1 file changed
+6 -3
+6 -3
View File
@@ -71,9 +71,12 @@
vm
};
if ($type === 'id') {
newProjectData.uniqueId = `#${$projectId}`;
newProjectData.projectId = $projectId;
const res = await fetch('https://projects.scratch.mit.edu/' + $projectId);
const match = $projectId.match(/\d+/);
if (!match) throw new Error('no project selected');
const id = match[0];
newProjectData.uniqueId = `#${id}`;
newProjectData.projectId = id;
const res = await fetch('https://projects.scratch.mit.edu/' + id);
const data = await res.arrayBuffer();
await vm.loadProject(data);
} else {