Skip to content

Commit

Permalink
Undo bad streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
bhollis committed May 11, 2023
1 parent 95d460e commit 1e86947
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "jsonview@brh.numbera.com",
"version": "2.4.0",
"version": "2.4.1",
"name": "jsonview",
"title": "JSONView",
"description": "View JSON documents in the browser.",
Expand Down
10 changes: 4 additions & 6 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ function transformResponseToJSON(details: chrome.webRequest.WebResponseHeadersDe

const dec = new TextDecoder("utf-8");
const enc = new TextEncoder();

filter.onstart = (_event) => {
filter.write(enc.encode("<!DOCTYPE html><html><body><pre>"));
};
let content = "";

filter.ondata = (event) => {
filter.write(enc.encode(dec.decode(event.data)));
content = content + dec.decode(event.data);
};

filter.onstop = (_event: Event) => {
filter.write(enc.encode("</pre></body></html>"));
const outputDoc = `<!DOCTYPE html><html><body><pre>${content}</pre></body></html>`;
filter.write(enc.encode(outputDoc));
filter.disconnect();
};
}
Expand Down

0 comments on commit 1e86947

Please sign in to comment.