diff --git a/server/routes.ts b/server/routes.ts index 5fa6cfc..8d97105 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -138,9 +138,13 @@ export async function registerRoutes(app: Express): Promise { const videoUrl = `${baseUrl}/video/${video.id}`; // Get high-quality thumbnail for sharing (1200x630 is ideal for Facebook) - const thumbnailUrl = video.thumbnailUrl - ? video.thumbnailUrl.replace('width=400&height=225', 'width=1200&height=630').replace('format=webp', 'format=jpg') - : `${baseUrl}/api/social-image`; + let thumbnailUrl = `${baseUrl}/api/social-image`; + if (video.thumbnailUrl) { + thumbnailUrl = video.thumbnailUrl + .replace(/width=\d+/gi, 'width=1200') + .replace(/height=\d+/gi, 'height=630') + .replace(/format=webp/gi, 'format=jpg'); + } // Clean description for meta tags const description = video.description @@ -162,6 +166,7 @@ export async function registerRoutes(app: Express): Promise { + @@ -1415,9 +1420,13 @@ export async function registerRoutes(app: Express): Promise { const videoUrl = `${baseUrl}/video/${video.id}`; // Get high-quality thumbnail for sharing (1200x630 is ideal for Facebook) - const thumbnailUrl = video.thumbnailUrl - ? video.thumbnailUrl.replace('width=400&height=225', 'width=1200&height=630').replace('format=webp', 'format=jpg') - : `${baseUrl}/api/social-image`; + let thumbnailUrl = `${baseUrl}/api/social-image`; + if (video.thumbnailUrl) { + thumbnailUrl = video.thumbnailUrl + .replace(/width=\d+/gi, 'width=1200') + .replace(/height=\d+/gi, 'height=630') + .replace(/format=webp/gi, 'format=jpg'); + } // Clean description for meta tags const description = video.description @@ -1439,6 +1448,7 @@ export async function registerRoutes(app: Express): Promise { +