Skip to content

Commit

Permalink
Simplified
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw authored Nov 19, 2024
1 parent 429eb88 commit 6025f62
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions zip-wheel-explorer.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,11 @@ <h1>Package File Browser</h1>

async function extractFiles(arrayBuffer, url) {
const files = [];

if (url.endsWith('.zip')) {
const zip = await JSZip.loadAsync(arrayBuffer);
for (const [name, file] of Object.entries(zip.files)) {
const content = await file.async('text');
files.push({ name, content });
}
} else if (url.endsWith('.tar.gz')) {
alert('tar not supported yet');
} else if (url.endsWith('.whl')) {
// Wheel files are zip files with a specific structure
const zip = await JSZip.loadAsync(arrayBuffer);
for (const [name, file] of Object.entries(zip.files)) {
const content = await file.async('text');
files.push({ name, content });
}
} else {
throw new Error('Unsupported file type');
const zip = await JSZip.loadAsync(arrayBuffer);
for (const [name, file] of Object.entries(zip.files)) {
const content = await file.async('text');
files.push({ name, content });
}

return files;
}
</script>
Expand Down

0 comments on commit 6025f62

Please sign in to comment.