my fork of the bluesky client

Fix start value in youtube embed by removing "s" from url param (#6113)

authored by

Lars Kappert and committed by
GitHub
f8fb6cb9 ab4e3611

+17 -2
+12
__tests__/lib/string.test.ts
··· 335 335 describe('parseEmbedPlayerFromUrl', () => { 336 336 const inputs = [ 337 337 'https://youtu.be/videoId', 338 + 'https://youtu.be/videoId?t=1s', 338 339 'https://www.youtube.com/watch?v=videoId', 339 340 'https://www.youtube.com/watch?v=videoId&feature=share', 341 + 'https://www.youtube.com/watch?v=videoId&t=1s', 340 342 'https://youtube.com/watch?v=videoId', 341 343 'https://youtube.com/watch?v=videoId&feature=share', 342 344 'https://youtube.com/shorts/videoId', ··· 444 446 { 445 447 type: 'youtube_video', 446 448 source: 'youtube', 449 + playerUri: 'https://bsky.app/iframe/youtube.html?videoId=videoId&start=1', 450 + }, 451 + { 452 + type: 'youtube_video', 453 + source: 'youtube', 447 454 playerUri: 'https://bsky.app/iframe/youtube.html?videoId=videoId&start=0', 448 455 }, 449 456 { 450 457 type: 'youtube_video', 451 458 source: 'youtube', 452 459 playerUri: 'https://bsky.app/iframe/youtube.html?videoId=videoId&start=0', 460 + }, 461 + { 462 + type: 'youtube_video', 463 + source: 'youtube', 464 + playerUri: 'https://bsky.app/iframe/youtube.html?videoId=videoId&start=1', 453 465 }, 454 466 { 455 467 type: 'youtube_video',
+5 -2
src/lib/strings/embed-player.ts
··· 88 88 // youtube 89 89 if (urlp.hostname === 'youtu.be') { 90 90 const videoId = urlp.pathname.split('/')[1] 91 - const seek = encodeURIComponent(urlp.searchParams.get('t') ?? 0) 91 + const t = urlp.searchParams.get('t') ?? '0' 92 + const seek = encodeURIComponent(t.replace(/s$/, '')) 93 + 92 94 if (videoId) { 93 95 return { 94 96 type: 'youtube_video', ··· 111 113 isShorts || isLive 112 114 ? shortOrLiveVideoId 113 115 : (urlp.searchParams.get('v') as string) 114 - const seek = encodeURIComponent(urlp.searchParams.get('t') ?? 0) 116 + const t = urlp.searchParams.get('t') ?? '0' 117 + const seek = encodeURIComponent(t.replace(/s$/, '')) 115 118 116 119 if (videoId) { 117 120 return {