Better starterpack embed (#4659)

This commit is contained in:
Hailey 2024-06-26 17:24:33 -07:00 committed by GitHub
parent da4dfeb9cf
commit 878b0476dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 103 additions and 32 deletions

View file

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