fix(servertools): Fix compression stream creation returns, handler proxy buffer conversion, and sitemap URL concatenation
This commit is contained in:
@ -111,6 +111,7 @@ export class Compressor {
|
||||
switch (method) {
|
||||
case 'gzip':
|
||||
compressionStream = plugins.zlib.createGzip();
|
||||
return compressionStream;
|
||||
case 'br':
|
||||
compressionStream = plugins.zlib.createBrotliCompress({
|
||||
chunkSize: 16 * 1024,
|
||||
@ -118,10 +119,13 @@ export class Compressor {
|
||||
|
||||
},
|
||||
});
|
||||
return compressionStream;
|
||||
case 'deflate':
|
||||
compressionStream = plugins.zlib.createDeflate();
|
||||
return compressionStream;
|
||||
default:
|
||||
compressionStream = plugins.smartstream.createPassThrough();
|
||||
return compressionStream;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -41,10 +41,11 @@ export class HandlerProxy extends Handler {
|
||||
}
|
||||
|
||||
let responseToSend: Buffer = proxiedResponse.body;
|
||||
if (typeof responseToSend !== 'string') {
|
||||
console.log(proxyRequestUrl);
|
||||
console.log(responseToSend);
|
||||
throw new Error(`Proxied response is not a string, but ${typeof responseToSend}`);
|
||||
|
||||
// Remove incorrect type check that expects responseToSend to be a string
|
||||
// Instead, ensure it's a Buffer for consistent handling
|
||||
if (!Buffer.isBuffer(responseToSend)) {
|
||||
responseToSend = Buffer.from(responseToSend.toString());
|
||||
}
|
||||
|
||||
if (optionsArg && optionsArg.responseModifier) {
|
||||
@ -74,4 +75,4 @@ export class HandlerProxy extends Handler {
|
||||
res.end();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -63,6 +63,6 @@ export class Sitemap {
|
||||
* adds urls to the current set of urls
|
||||
*/
|
||||
public addUrls(urlsArg: IUrlInfo[]) {
|
||||
this.urls = this.urls.concat(this.urls, urlsArg);
|
||||
this.urls = this.urls.concat(urlsArg);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user