*Add temp hack to filter out inline source maps
This commit is contained in:
parent
2450390229
commit
67d94d1c47
|
@ -103,9 +103,11 @@ export default class IpfsProvider extends BaseProvider {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleProxy(details: OnRequestDetailsType): Promise<any> {
|
async handleProxy(details: OnRequestDetailsType): Promise<any> {
|
||||||
return requestProxies;
|
return requestProxies;
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleReqHeaders(
|
async handleReqHeaders(
|
||||||
details: OnBeforeSendHeadersDetailsType
|
details: OnBeforeSendHeadersDetailsType
|
||||||
): Promise<BlockingResponse | boolean> {
|
): Promise<BlockingResponse | boolean> {
|
||||||
|
@ -247,23 +249,30 @@ export default class IpfsProvider extends BaseProvider {
|
||||||
if (buffer.length) {
|
if (buffer.length) {
|
||||||
let mode = contentModes[contentType as string];
|
let mode = contentModes[contentType as string];
|
||||||
if (mode === CONTENT_MODE_BUFFERED) {
|
if (mode === CONTENT_MODE_BUFFERED) {
|
||||||
filter.write(
|
let data: string | Uint8Array = Uint8Array.from(
|
||||||
Uint8Array.from(
|
|
||||||
buffer.reduce(
|
buffer.reduce(
|
||||||
(previousValue: Uint8Array, currentValue: Uint8Array) => {
|
(previousValue: Uint8Array, currentValue: Uint8Array) => {
|
||||||
return Uint8Array.from([...previousValue, ...currentValue]);
|
return Uint8Array.from([...previousValue, ...currentValue]);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
if (contentType === "application/javascript") {
|
||||||
|
data = new TextDecoder("utf-8", { fatal: true }).decode(data);
|
||||||
|
data = data.replace(
|
||||||
|
/\/\/#\s*sourceMappingURL=([^\.]+)\.js.map/,
|
||||||
|
""
|
||||||
|
);
|
||||||
|
data = new TextEncoder().encode(data);
|
||||||
|
}
|
||||||
|
filter.write(data);
|
||||||
} else if (mode == CONTENT_MODE_CHUNKED) {
|
} else if (mode == CONTENT_MODE_CHUNKED) {
|
||||||
buffer.forEach(filter.write);
|
buffer.forEach((data) => filter.write(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
filter.close();
|
filter.close();
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.log("page error", urlPath, e.message);
|
console.error("page error", urlPath, e.message);
|
||||||
/* if (
|
/* if (
|
||||||
urlPath.endsWith(".html") ||
|
urlPath.endsWith(".html") ||
|
||||||
urlPath.endsWith(".htm") ||
|
urlPath.endsWith(".htm") ||
|
||||||
|
|
Reference in New Issue