aboutsummaryrefslogtreecommitdiffstats
path: root/apps/workers/network.ts
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--apps/workers/network.ts11
1 files changed, 10 insertions, 1 deletions
diff --git a/apps/workers/network.ts b/apps/workers/network.ts
index 0dc46da4..2ef8483f 100644
--- a/apps/workers/network.ts
+++ b/apps/workers/network.ts
@@ -86,6 +86,15 @@ function isAddressForbidden(address: string): boolean {
return DISALLOWED_IP_RANGES.has(parsed.range());
}
+export function getBookmarkDomain(url?: string | null): string | undefined {
+ if (!url) return undefined;
+ try {
+ return new URL(url).hostname;
+ } catch {
+ return undefined;
+ }
+}
+
export type UrlValidationResult =
| { ok: true; url: URL }
| { ok: false; reason: string };
@@ -163,7 +172,7 @@ export async function validateUrl(
if (isAddressForbidden(hostname)) {
return {
ok: false,
- reason: `Refusing to access disallowed IP address ${hostname} (requested via ${parsedUrl.toString()})`,
+ reason: `Refusing to access disallowed IP address ${hostname} (requested via ${parsedUrl.toString()}). You can use CRAWLER_ALLOWED_INTERNAL_HOSTNAMES to allowlist specific hostnames for internal access.`,
} as const;
}
return { ok: true, url: parsedUrl } as const;