about summary refs log tree commit diff
path: root/src/lib/strings/url-helpers.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-03-03 16:30:33 -0600
committerGitHub <noreply@github.com>2023-03-03 16:30:33 -0600
commit8e22ce8e2a4739e5e9e90589764aff55ee73a5db (patch)
tree0a45b9dc84190af387fbb408c16bdb79daed2e56 /src/lib/strings/url-helpers.ts
parentd74ff9c2199ed9487a90413d076459638b07c470 (diff)
downloadvoidsky-8e22ce8e2a4739e5e9e90589764aff55ee73a5db.tar.zst
Turn links to posts into quote posts (#262)
* Turn links to posts into quote posts

* Fix lint
Diffstat (limited to 'src/lib/strings/url-helpers.ts')
-rw-r--r--src/lib/strings/url-helpers.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/strings/url-helpers.ts b/src/lib/strings/url-helpers.ts
index a149f49c3..1fa30a3ef 100644
--- a/src/lib/strings/url-helpers.ts
+++ b/src/lib/strings/url-helpers.ts
@@ -66,6 +66,18 @@ export function isBskyAppUrl(url: string): boolean {
   return url.startsWith('https://bsky.app/')
 }
 
+export function isBskyPostUrl(url: string): boolean {
+  if (isBskyAppUrl(url)) {
+    try {
+      const urlp = new URL(url)
+      return /profile\/(?<name>[^/]+)\/post\/(?<rkey>[^/]+)/i.test(
+        urlp.pathname,
+      )
+    } catch {}
+  }
+  return false
+}
+
 export function convertBskyAppUrlIfNeeded(url: string): string {
   if (isBskyAppUrl(url)) {
     try {