diff --git a/src/contentProviders/ipfsProvider.ts b/src/contentProviders/ipfsProvider.ts index 16d51c8..4ac2f8c 100644 --- a/src/contentProviders/ipfsProvider.ts +++ b/src/contentProviders/ipfsProvider.ts @@ -121,11 +121,18 @@ export default class IpfsProvider extends BaseProvider { async handleRequest( details: OnBeforeRequestDetailsType ): Promise { - let urlPath = new URL(details.url).pathname; + let urlObj = new URL(details.url); + let urlPath = urlObj.pathname; let hash = this.getData(details, "hash"); let resp: StatFileResponse | null = null; let fetchMethod: typeof fetchIpfs | typeof fetchIpns; let err; + + if (urlObj.protocol == "https") { + urlObj.protocol = "http"; + return { redirectUrl: urlObj.toString() }; + } + try { if (ipfsPath(hash)) { hash = hash.replace("/ipfs/", ""); @@ -264,6 +271,23 @@ export default class IpfsProvider extends BaseProvider { ); data = new TextEncoder().encode(data); } + /* if (contentType === "text/html") { + data = new TextDecoder("utf-8", { fatal: true }).decode(data); + let htmlDoc = new DOMParser().parseFromString( + data as string, + contentType + ); + let found = htmlDoc.documentElement.querySelectorAll( + 'meta[http-equiv="Content-Security-Policy"]' + ); + + if (found.length) { + found.forEach((item) => item.remove()); + data = htmlDoc.documentElement.outerHTML; + } + + data = new TextEncoder().encode(data); + }*/ filter.write(data); } else if (mode == CONTENT_MODE_CHUNKED) { buffer.forEach((data) => filter.write(data)); diff --git a/src/contentProviders/skynetProvider.ts b/src/contentProviders/skynetProvider.ts index 4cc70a3..f776b1e 100644 --- a/src/contentProviders/skynetProvider.ts +++ b/src/contentProviders/skynetProvider.ts @@ -31,8 +31,15 @@ export default class SkynetProvider extends BaseProvider { details: OnBeforeRequestDetailsType ): Promise { const dns = await this.resolveDns(details); - let path = new URL(details.url).pathname; + let urlObj = new URL(details.url); + let path = urlObj.pathname; let fileData: any, err; + + if (urlObj.protocol == "https") { + urlObj.protocol = "http"; + return { redirectUrl: urlObj.toString() }; + } + try { [fileData, err] = await downloadSkylink(dns, path); } catch (e: any) {