Skip to content

Commit 1e86947

Browse files
committed
Undo bad streaming
1 parent 95d460e commit 1e86947

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "jsonview@brh.numbera.com",
3-
"version": "2.4.0",
3+
"version": "2.4.1",
44
"name": "jsonview",
55
"title": "JSONView",
66
"description": "View JSON documents in the browser.",

src/background.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,15 @@ function transformResponseToJSON(details: chrome.webRequest.WebResponseHeadersDe
2727

2828
const dec = new TextDecoder("utf-8");
2929
const enc = new TextEncoder();
30-
31-
filter.onstart = (_event) => {
32-
filter.write(enc.encode("<!DOCTYPE html><html><body><pre>"));
33-
};
30+
let content = "";
3431

3532
filter.ondata = (event) => {
36-
filter.write(enc.encode(dec.decode(event.data)));
33+
content = content + dec.decode(event.data);
3734
};
3835

3936
filter.onstop = (_event: Event) => {
40-
filter.write(enc.encode("</pre></body></html>"));
37+
const outputDoc = `<!DOCTYPE html><html><body><pre>${content}</pre></body></html>`;
38+
filter.write(enc.encode(outputDoc));
4139
filter.disconnect();
4240
};
4341
}

0 commit comments

Comments
 (0)