From e73d68cac47325b2afd4b38c80883e6c014d438c Mon Sep 17 00:00:00 2001 From: forehalo Date: Fri, 11 Apr 2025 09:36:20 +0000 Subject: [PATCH] chore(server): fix spotify link preview (#11638) close AF-2499 --- .../backend/server/src/plugins/worker/utils/url.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/backend/server/src/plugins/worker/utils/url.ts b/packages/backend/server/src/plugins/worker/utils/url.ts index 3253cc8779..40591bd0ea 100644 --- a/packages/backend/server/src/plugins/worker/utils/url.ts +++ b/packages/backend/server/src/plugins/worker/utils/url.ts @@ -4,6 +4,14 @@ import { imageProxyBuilder } from './proxy'; const localhost = new Set(['localhost', '127.0.0.1']); +const URL_FIXERS: Record URL> = { + 'open.spotify.com': (url: URL) => { + // with si query, spotify will redirect to landing page which [Open Desktop] check + url.searchParams.delete('si'); + return url; + }, +}; + export function fixUrl(url?: string): URL | null { if (typeof url !== 'string') { return null; @@ -28,6 +36,12 @@ export function fixUrl(url?: string): URL | null { // check hostname is a valid domain (fullDomain === parsed.hostname || localhost.has(parsed.hostname)) ) { + const fixer = URL_FIXERS[parsed.hostname]; + + if (fixer) { + return fixer(parsed); + } + return parsed; } } catch {}