From 878b0476dd94e187504f503438ca8914a48ac630 Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 26 Jun 2024 17:24:33 -0700 Subject: Better starterpack embed (#4659) --- src/lib/strings/url-helpers.ts | 11 +++++++++++ 1 file changed, 11 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 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 + } +} -- cgit 1.4.1