Merge pull request #1290 from jvanbruegge/fix-http-links

fix INVALID_PROTOCOL when saving http website
This commit is contained in:
Daniel
2025-10-04 04:08:02 -04:00
committed by GitHub
2 changed files with 14 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
import fetch from "node-fetch";
import https from "https";
import http from "http";
import { HttpsProxyAgent } from "https-proxy-agent";
import { SocksProxyAgent } from "socks-proxy-agent";
@@ -8,10 +9,12 @@ export default async function fetchTitleAndHeaders(url: string) {
return { title: "", headers: null };
try {
const httpsAgent = new https.Agent({
rejectUnauthorized:
process.env.IGNORE_UNAUTHORIZED_CA === "true" ? false : true,
});
const httpsAgent = url?.startsWith("http://")
? new http.Agent({})
: new https.Agent({
rejectUnauthorized:
process.env.IGNORE_UNAUTHORIZED_CA === "true" ? false : true,
});
// fetchOpts allows a proxy to be defined
let fetchOpts = {

View File

@@ -1,5 +1,6 @@
import fetch from "node-fetch";
import https from "https";
import http from "http";
import { HttpsProxyAgent } from 'https-proxy-agent';
import { SocksProxyAgent } from "socks-proxy-agent";
@@ -7,10 +8,12 @@ export default async function fetchHeaders(url: string) {
if (process.env.IGNORE_URL_SIZE_LIMIT === "true") return null;
try {
const httpsAgent = new https.Agent({
rejectUnauthorized:
process.env.IGNORE_UNAUTHORIZED_CA === "true" ? false : true,
});
const httpsAgent = url.startsWith("http://")
? new http.Agent({})
: new https.Agent({
rejectUnauthorized:
process.env.IGNORE_UNAUTHORIZED_CA === "true" ? false : true,
});
let fetchOpts = {
method: "HEAD",