Skip to content

Commit 37ef203

Browse files
committed
frontend/Frame: fix type error
1 parent 1657997 commit 37ef203

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

frontend/src/pages/Frame.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,16 +187,24 @@ class VirtualNetworkInterface {
187187
break;
188188

189189
case MessageType.FileDownload:
190-
const blob = new Blob([msg.data as Uint8Array]);
191-
const url = URL.createObjectURL(blob)
192-
if (Median.isNativeApp()) {
193-
Median.share.downloadFile({url, filename: "out.pcap"});
194-
} else {
195-
const a = document.createElement("a");
196-
a.href = url;
197-
a.download = "out.pcap";
198-
a.target = "_blank";
199-
a.click();
190+
if (!(msg.data instanceof Uint8Array)) {
191+
console.error("Expected Uint8Array for FileDownload message, got", msg.data);
192+
break;
193+
}
194+
{
195+
const copy = new Uint8Array(msg.data.length);
196+
copy.set(msg.data);
197+
const blob = new Blob([copy.buffer], {type: 'application/vnd.tcpdump.pcap'});
198+
const url = URL.createObjectURL(blob);
199+
if (Median.isNativeApp()) {
200+
Median.share.downloadFile({url, filename: "out.pcap"});
201+
} else {
202+
const a = document.createElement("a");
203+
a.href = url;
204+
a.download = "out.pcap";
205+
a.target = "_blank";
206+
a.click();
207+
}
200208
}
201209
break;
202210

0 commit comments

Comments
 (0)