Skip to content

Commit

Permalink
Support artifact:// URLs on wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
pipe01 committed Oct 30, 2024
1 parent 9e9533f commit 30e32e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions frontend/wasm/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import { computed, ref } from 'vue';
import Emulator from "@/components/Emulator.vue";
import { resolveArtifactUrl } from './utils';
const pickedFile = ref<ArrayBuffer | null>(null);
const isLoading = ref(0);
Expand All @@ -67,11 +68,11 @@ async function parseOptions(params: URLSearchParams) {
isLoading.value++;
if (params.has("firmware")) {
await loadFileFromURL(params.get("firmware")!);
await loadFileFromURL(resolveArtifactUrl(params.get("firmware")!));
}
if (params.has("resources")) {
for (const url of params.getAll("resources")) {
const response = await fetch(url);
const response = await fetch(resolveArtifactUrl(url));
const resource = new Uint8Array(await response.arrayBuffer());
initResources.value.push(resource);
Expand Down
9 changes: 9 additions & 0 deletions frontend/wasm/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,12 @@ export async function getZipOrNested(data: Uint8Array, maxDepth = 5): Promise<FS
return zip;
}
}

export function resolveArtifactUrl(url: string) {
const matches = /artifact:\/\/(.+\/.+)\/(\d+)/.exec(url);
if (matches) {
return `https://corsproxy.io/?https://nightly.link/${matches[1]}/actions/artifacts/${matches[2]}.zip`;
}

return url;
}

0 comments on commit 30e32e8

Please sign in to comment.