aboutsummaryrefslogtreecommitdiffstats
path: root/apps/workers
diff options
context:
space:
mode:
Diffstat (limited to 'apps/workers')
-rw-r--r--apps/workers/network.ts12
1 files changed, 9 insertions, 3 deletions
diff --git a/apps/workers/network.ts b/apps/workers/network.ts
index acfd2439..d1cda62c 100644
--- a/apps/workers/network.ts
+++ b/apps/workers/network.ts
@@ -7,6 +7,7 @@ import { LRUCache } from "lru-cache";
import fetch, { Headers } from "node-fetch";
import serverConfig from "@karakeep/shared/config";
+import logger from "@karakeep/shared/logger";
const DISALLOWED_IP_RANGES = new Set([
// IPv4 ranges
@@ -212,9 +213,14 @@ export function getRandomProxy(proxyList: string[]): string {
}
export function matchesNoProxy(url: string, noProxy: string[]) {
- const urlObj = new URL(url);
- const hostname = urlObj.hostname;
- return hostnameMatchesAnyPattern(hostname, noProxy);
+ try {
+ const urlObj = new URL(url);
+ const hostname = urlObj.hostname;
+ return hostnameMatchesAnyPattern(hostname, noProxy);
+ } catch (e) {
+ logger.error(`Failed to parse URL: ${url}: ${e}`);
+ return false;
+ }
}
export function getProxyAgent(url: string) {