From 8e22ce8e2a4739e5e9e90589764aff55ee73a5db Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Fri, 3 Mar 2023 16:30:33 -0600 Subject: Turn links to posts into quote posts (#262) * Turn links to posts into quote posts * Fix lint --- src/lib/strings/url-helpers.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/lib/strings/url-helpers.ts') 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\/(?[^/]+)\/post\/(?[^/]+)/i.test( + urlp.pathname, + ) + } catch {} + } + return false +} + export function convertBskyAppUrlIfNeeded(url: string): string { if (isBskyAppUrl(url)) { try { -- cgit 1.4.1