diff --git a/__tests__/lib/string.test.ts b/__tests__/lib/string.test.ts index 8d999ba7af..753262a4f6 100644 --- a/__tests__/lib/string.test.ts +++ b/__tests__/lib/string.test.ts @@ -858,7 +858,7 @@ describe('parseEmbedPlayerFromUrl', () => { source: 'klipy', isGif: 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: { width: 300, height: 200, @@ -1080,10 +1080,10 @@ describe('klipyUrlToBskyGifUrl', () => { ] 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 => { 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', ) 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', ) }) diff --git a/src/lib/strings/embed-player.ts b/src/lib/strings/embed-player.ts index 96978550b4..d8a5999797 100644 --- a/src/lib/strings/embed-player.ts +++ b/src/lib/strings/embed-player.ts @@ -684,9 +684,11 @@ export function parseKlipyGif(urlp: URL): } // 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) - playerUrl.hostname = 't.gifs.bsky.app' + playerUrl.hostname = 'k.gifs.bsky.app' playerUrl.searchParams.delete('hh') playerUrl.searchParams.delete('ww') diff --git a/src/state/queries/klipy.ts b/src/state/queries/klipy.ts index 4b646fb405..f87e031e31 100644 --- a/src/state/queries/klipy.ts +++ b/src/state/queries/klipy.ts @@ -91,7 +91,9 @@ function createKlipyApi( /** * 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) { let url @@ -101,6 +103,6 @@ export function klipyUrlToBskyGifUrl(klipyUrl: string) { logger.debug('invalid url passed to klipyUrlToBskyGifUrl()') return '' } - url.hostname = 't.gifs.bsky.app' + url.hostname = 'k.gifs.bsky.app' return url.href } diff --git a/src/state/queries/tenor.ts b/src/state/queries/tenor.ts index 310fa308b8..97ce426e72 100644 --- a/src/state/queries/tenor.ts +++ b/src/state/queries/tenor.ts @@ -105,19 +105,20 @@ export function tenorUrlToBskyGifUrl(tenorUrl: string) { /** * Returns the appropriate URL for a GIF preview image. - * Both Tenor (media.tenor.com) and KLIPY (static.klipy.com) URLs are - * rewritten through the bsky proxy at t.gifs.bsky.app. + * Tenor URLs (media.tenor.com) are routed through t.gifs.bsky.app; + * KLIPY URLs (static.klipy.com) are routed through k.gifs.bsky.app. */ export function gifPreviewUrl(gifUrl: string) { try { const url = new URL(gifUrl) - if ( - url.hostname === 'media.tenor.com' || - url.hostname === 'static.klipy.com' - ) { + if (url.hostname === 'media.tenor.com') { url.hostname = 't.gifs.bsky.app' return url.href } + if (url.hostname === 'static.klipy.com') { + url.hostname = 'k.gifs.bsky.app' + return url.href + } return gifUrl } catch (e) { logger.debug('invalid url passed to gifPreviewUrl()')