This commit is contained in:
vineyardbovines
2026-04-15 12:33:51 -04:00
parent 3d09ee8bb2
commit b7f2c359f6
4 changed files with 43 additions and 19 deletions
+8 -7
View File
@@ -90,16 +90,17 @@ function createKlipyApi<Input extends object>(
}
/**
* Returns the static URL for a KLIPY GIF preview image.
* KLIPY images are served directly from their CDN (static.klipy.com),
* unlike Tenor which routes through t.gifs.bsky.app.
* Rewrites a KLIPY static CDN URL through the bsky proxy
* (t.gifs.bsky.app), matching the behavior of `tenorUrlToBskyGifUrl`.
*/
export function klipyStaticUrl(gifUrl: string) {
export function klipyUrlToBskyGifUrl(klipyUrl: string) {
let url
try {
new URL(gifUrl)
return gifUrl
url = new URL(klipyUrl)
} catch (e) {
logger.debug('invalid url passed to klipyStaticUrl()')
logger.debug('invalid url passed to klipyUrlToBskyGifUrl()')
return ''
}
url.hostname = 't.gifs.bsky.app'
return url.href
}
+8 -4
View File
@@ -105,14 +105,18 @@ export function tenorUrlToBskyGifUrl(tenorUrl: string) {
/**
* Returns the appropriate URL for a GIF preview image.
* Rewrites Tenor URLs through the bsky proxy (t.gifs.bsky.app);
* KLIPY URLs pass through directly to their CDN.
* Both Tenor (media.tenor.com) and KLIPY (static.klipy.com) URLs are
* rewritten through the bsky proxy at t.gifs.bsky.app.
*/
export function gifPreviewUrl(gifUrl: string) {
try {
const url = new URL(gifUrl)
if (url.hostname === 'media.tenor.com') {
return tenorUrlToBskyGifUrl(gifUrl)
if (
url.hostname === 'media.tenor.com' ||
url.hostname === 'static.klipy.com'
) {
url.hostname = 't.gifs.bsky.app'
return url.href
}
return gifUrl
} catch (e) {