update klipy cdn path

This commit is contained in:
vineyardbovines
2026-04-15 13:33:26 -04:00
parent c402fbbe26
commit ceea6bcf3c
4 changed files with 19 additions and 14 deletions
+4 -4
View File
@@ -858,7 +858,7 @@ describe('parseEmbedPlayerFromUrl', () => {
source: 'klipy', source: 'klipy',
isGif: true, isGif: true,
hideDetails: true, hideDetails: true,
playerUri: 'https://t.gifs.bsky.app/ii/abc123/73/ac/someFile.gif', playerUri: 'https://k.gifs.bsky.app/ii/abc123/73/ac/someFile.gif',
dimensions: { dimensions: {
width: 300, width: 300,
height: 200, height: 200,
@@ -1080,10 +1080,10 @@ describe('klipyUrlToBskyGifUrl', () => {
] ]
it.each(inputs)( it.each(inputs)(
'returns url with t.gifs.bsky.app as hostname for input url', 'returns url with k.gifs.bsky.app as hostname for input url',
input => { input => {
const out = klipyUrlToBskyGifUrl(input) const out = klipyUrlToBskyGifUrl(input)
expect(out.startsWith('https://t.gifs.bsky.app/')).toEqual(true) expect(out.startsWith('https://k.gifs.bsky.app/')).toEqual(true)
}, },
) )
@@ -1092,7 +1092,7 @@ describe('klipyUrlToBskyGifUrl', () => {
'https://static.klipy.com/ii/abc123/73/ac/someFile.gif?hh=200&ww=300', 'https://static.klipy.com/ii/abc123/73/ac/someFile.gif?hh=200&ww=300',
) )
expect(out).toEqual( expect(out).toEqual(
'https://t.gifs.bsky.app/ii/abc123/73/ac/someFile.gif?hh=200&ww=300', 'https://k.gifs.bsky.app/ii/abc123/73/ac/someFile.gif?hh=200&ww=300',
) )
}) })
+4 -2
View File
@@ -684,9 +684,11 @@ export function parseKlipyGif(urlp: URL):
} }
// Use the base URL without dimension params as the player URI, // Use the base URL without dimension params as the player URI,
// routed through the bsky proxy (t.gifs.bsky.app) — matching Tenor. // routed through the bsky KLIPY proxy (k.gifs.bsky.app). Mirrors
// Tenor's t.gifs.bsky.app rewrite, but on a separate hostname so
// the two upstreams can be routed independently.
const playerUrl = new URL(urlp.href) const playerUrl = new URL(urlp.href)
playerUrl.hostname = 't.gifs.bsky.app' playerUrl.hostname = 'k.gifs.bsky.app'
playerUrl.searchParams.delete('hh') playerUrl.searchParams.delete('hh')
playerUrl.searchParams.delete('ww') playerUrl.searchParams.delete('ww')
+4 -2
View File
@@ -91,7 +91,9 @@ function createKlipyApi<Input extends object>(
/** /**
* Rewrites a KLIPY static CDN URL through the bsky proxy * Rewrites a KLIPY static CDN URL through the bsky proxy
* (t.gifs.bsky.app), matching the behavior of `tenorUrlToBskyGifUrl`. * (k.gifs.bsky.app). Mirrors `tenorUrlToBskyGifUrl`, but uses a
* separate hostname from Tenor's t.gifs.bsky.app so the two
* upstreams can be routed independently.
*/ */
export function klipyUrlToBskyGifUrl(klipyUrl: string) { export function klipyUrlToBskyGifUrl(klipyUrl: string) {
let url let url
@@ -101,6 +103,6 @@ export function klipyUrlToBskyGifUrl(klipyUrl: string) {
logger.debug('invalid url passed to klipyUrlToBskyGifUrl()') logger.debug('invalid url passed to klipyUrlToBskyGifUrl()')
return '' return ''
} }
url.hostname = 't.gifs.bsky.app' url.hostname = 'k.gifs.bsky.app'
return url.href return url.href
} }
+7 -6
View File
@@ -105,19 +105,20 @@ export function tenorUrlToBskyGifUrl(tenorUrl: string) {
/** /**
* Returns the appropriate URL for a GIF preview image. * Returns the appropriate URL for a GIF preview image.
* Both Tenor (media.tenor.com) and KLIPY (static.klipy.com) URLs are * Tenor URLs (media.tenor.com) are routed through t.gifs.bsky.app;
* rewritten through the bsky proxy at t.gifs.bsky.app. * KLIPY URLs (static.klipy.com) are routed through k.gifs.bsky.app.
*/ */
export function gifPreviewUrl(gifUrl: string) { export function gifPreviewUrl(gifUrl: string) {
try { try {
const url = new URL(gifUrl) const url = new URL(gifUrl)
if ( if (url.hostname === 'media.tenor.com') {
url.hostname === 'media.tenor.com' ||
url.hostname === 'static.klipy.com'
) {
url.hostname = 't.gifs.bsky.app' url.hostname = 't.gifs.bsky.app'
return url.href return url.href
} }
if (url.hostname === 'static.klipy.com') {
url.hostname = 'k.gifs.bsky.app'
return url.href
}
return gifUrl return gifUrl
} catch (e) { } catch (e) {
logger.debug('invalid url passed to gifPreviewUrl()') logger.debug('invalid url passed to gifPreviewUrl()')