about summary refs log tree commit diff
path: root/src/lib/strings/url-helpers.ts
diff options
context:
space:
mode:
authorHailey <me@haileyok.com>2024-06-26 17:24:33 -0700
committerGitHub <noreply@github.com>2024-06-26 17:24:33 -0700
commit878b0476dd94e187504f503438ca8914a48ac630 (patch)
treea51386f8b6f3e1e11b5b5d668f7a4f3f77b91e69 /src/lib/strings/url-helpers.ts
parentda4dfeb9cf6506ade2a9619921de128458c4d0d2 (diff)
downloadvoidsky-878b0476dd94e187504f503438ca8914a48ac630.tar.zst
Better starterpack embed (#4659)
Diffstat (limited to 'src/lib/strings/url-helpers.ts')
-rw-r--r--src/lib/strings/url-helpers.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/strings/url-helpers.ts b/src/lib/strings/url-helpers.ts
index 4c75f47ad..b88b77f73 100644
--- a/src/lib/strings/url-helpers.ts
+++ b/src/lib/strings/url-helpers.ts
@@ -2,6 +2,7 @@ import {AtUri} from '@atproto/api'
 import psl from 'psl'
 import TLDs from 'tlds'
 
+import {logger} from '#/logger'
 import {BSKY_SERVICE} from 'lib/constants'
 import {isInvalidHandle} from 'lib/strings/handles'
 
@@ -285,3 +286,13 @@ export function createBskyAppAbsoluteUrl(path: string): string {
   const sanitizedPath = path.replace(BSKY_APP_HOST, '').replace(/^\/+/, '')
   return `${BSKY_APP_HOST.replace(/\/$/, '')}/${sanitizedPath}`
 }
+
+export function isShortLink(url: string): boolean {
+  try {
+    const urlp = new URL(url)
+    return urlp.host === 'go.bsky.app'
+  } catch (e) {
+    logger.error('Failed to parse possible short link', {safeMessage: e})
+    return false
+  }
+}