aboutsummaryrefslogtreecommitdiffstats
path: root/apps/workers/network.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/workers/network.ts')
-rw-r--r--apps/workers/network.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/apps/workers/network.ts b/apps/workers/network.ts
index 4bc30562..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 };