about summary refs log tree commit diff
path: root/src/lib/strings
diff options
context:
space:
mode:
authorHailey <me@haileyok.com>2025-02-27 13:18:30 -0800
committerGitHub <noreply@github.com>2025-02-27 13:18:30 -0800
commita2b71e3a4b786565938cef60924b27c5cd7f0660 (patch)
treeff78bc233ab5c1507b3f13f2dcbeaac96974ad07 /src/lib/strings
parenta3d36393a16b6219d97d2a553aa426ab108f3168 (diff)
downloadvoidsky-a2b71e3a4b786565938cef60924b27c5cd7f0660.tar.zst
tweak link handling (#7857)
Diffstat (limited to 'src/lib/strings')
-rw-r--r--src/lib/strings/url-helpers.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/strings/url-helpers.ts b/src/lib/strings/url-helpers.ts
index c44fdf7c2..bb533b12e 100644
--- a/src/lib/strings/url-helpers.ts
+++ b/src/lib/strings/url-helpers.ts
@@ -320,6 +320,21 @@ export function createBskyAppAbsoluteUrl(path: string): string {
   return `${BSKY_APP_HOST.replace(/\/$/, '')}/${sanitizedPath}`
 }
 
+export function createProxiedUrl(url: string): string {
+  let u
+  try {
+    u = URL.parse(url)
+  } catch {
+    return url
+  }
+
+  if (u?.protocol !== 'http:' && u?.protocol !== 'https:') {
+    return url
+  }
+
+  return `https://go.bsky.app/redirect?u=${url}`
+}
+
 export function isShortLink(url: string): boolean {
   return url.startsWith('https://go.bsky.app/')
 }