diff options
Diffstat (limited to 'src/server/server_Initialization.ts')
-rw-r--r-- | src/server/server_Initialization.ts | 20 |
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); } } }); |