Turn links to posts into quote posts (#262)

* Turn links to posts into quote posts

* Fix lint
This commit is contained in:
Paul Frazee 2023-03-03 16:30:33 -06:00 committed by GitHub
parent d74ff9c219
commit 8e22ce8e2a
3 changed files with 73 additions and 10 deletions

View file

@ -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 {