aboutsummaryrefslogtreecommitdiff
path: root/src/server/server_Initialization.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2022-02-09 08:59:32 -0500
committerbobzel <zzzman@gmail.com>2022-02-09 08:59:32 -0500
commita6d904bcd18a2c9962abfd9b5b325340f6b18b0d (patch)
tree32ab8f94e8f742d9303ec06029247931f1ab3895 /src/server/server_Initialization.ts
parent66fb0e4bbf88a5e9bcb5869dd7c8b8a7714de024 (diff)
speeding up rendering using bitmaps for webpages and other heavyweight docs.
Diffstat (limited to 'src/server/server_Initialization.ts')
-rw-r--r--src/server/server_Initialization.ts20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/server/server_Initialization.ts b/src/server/server_Initialization.ts
index de93b64c3..b06437907 100644
--- a/src/server/server_Initialization.ts
+++ b/src/server/server_Initialization.ts
@@ -178,11 +178,21 @@ function proxyServe(req: any, requrl: string, response: any) {
return `href="${resolvedServerUrl + "/corsProxy/http" + href}"`;
};
const zipToStringDecoder = new (require('string_decoder').StringDecoder)('utf8');
- const htmlText = zipToStringDecoder.write(zlib.gunzipSync(htmlBodyMemoryStream.read()).toString('utf8')
- .replace('<head>', '<head> <style>[id ^= "google"] { display: none; } </style>')
- .replace(/href="http([^"]*)"/g, replacer)
- .replace(/target="_blank"/g, ""));
- rewrittenHtmlBody = zlib.gzipSync(htmlText);
+ // const htmlText = zipToStringDecoder.write(zlib.gunzipSync(htmlBodyMemoryStream.read()).toString('utf8')
+ // .replace('<head>', '<head> <style>[id ^= "google"] { display: none; } </style>')
+ // .replace(/href="http([^"]*)"/g, replacer)
+ // .replace(/target="_blank"/g, ""));
+ // rewrittenHtmlBody = zlib.gzipSync(htmlText);
+ const bodyStream = htmlBodyMemoryStream.read();
+ if (bodyStream) {
+ const htmlText = zipToStringDecoder.write(zlib.gunzipSync(bodyStream).toString('utf8')
+ .replace('<head>', '<head> <style>[id ^= "google"] { display: none; } </style>')
+ // .replace(/href="http([^"]*)"/g, replacer)
+ .replace(/target="_blank"/g, ""));
+ rewrittenHtmlBody = zlib.gzipSync(htmlText);
+ } else {
+ console.log("EMPTY body: href");
+ }
} catch (e) { console.log(e); }
}
});