Fix start value in youtube embed by removing "s" from url param (#6113)
This commit is contained in:
@@ -335,8 +335,10 @@ describe('shortenLinks', () => {
|
|||||||
describe('parseEmbedPlayerFromUrl', () => {
|
describe('parseEmbedPlayerFromUrl', () => {
|
||||||
const inputs = [
|
const inputs = [
|
||||||
'https://youtu.be/videoId',
|
'https://youtu.be/videoId',
|
||||||
|
'https://youtu.be/videoId?t=1s',
|
||||||
'https://www.youtube.com/watch?v=videoId',
|
'https://www.youtube.com/watch?v=videoId',
|
||||||
'https://www.youtube.com/watch?v=videoId&feature=share',
|
'https://www.youtube.com/watch?v=videoId&feature=share',
|
||||||
|
'https://www.youtube.com/watch?v=videoId&t=1s',
|
||||||
'https://youtube.com/watch?v=videoId',
|
'https://youtube.com/watch?v=videoId',
|
||||||
'https://youtube.com/watch?v=videoId&feature=share',
|
'https://youtube.com/watch?v=videoId&feature=share',
|
||||||
'https://youtube.com/shorts/videoId',
|
'https://youtube.com/shorts/videoId',
|
||||||
@@ -441,6 +443,11 @@ describe('parseEmbedPlayerFromUrl', () => {
|
|||||||
source: 'youtube',
|
source: 'youtube',
|
||||||
playerUri: 'https://bsky.app/iframe/youtube.html?videoId=videoId&start=0',
|
playerUri: 'https://bsky.app/iframe/youtube.html?videoId=videoId&start=0',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'youtube_video',
|
||||||
|
source: 'youtube',
|
||||||
|
playerUri: 'https://bsky.app/iframe/youtube.html?videoId=videoId&start=1',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: 'youtube_video',
|
type: 'youtube_video',
|
||||||
source: 'youtube',
|
source: 'youtube',
|
||||||
@@ -451,6 +458,11 @@ describe('parseEmbedPlayerFromUrl', () => {
|
|||||||
source: 'youtube',
|
source: 'youtube',
|
||||||
playerUri: 'https://bsky.app/iframe/youtube.html?videoId=videoId&start=0',
|
playerUri: 'https://bsky.app/iframe/youtube.html?videoId=videoId&start=0',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'youtube_video',
|
||||||
|
source: 'youtube',
|
||||||
|
playerUri: 'https://bsky.app/iframe/youtube.html?videoId=videoId&start=1',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: 'youtube_video',
|
type: 'youtube_video',
|
||||||
source: 'youtube',
|
source: 'youtube',
|
||||||
|
|||||||
@@ -88,7 +88,9 @@ export function parseEmbedPlayerFromUrl(
|
|||||||
// youtube
|
// youtube
|
||||||
if (urlp.hostname === 'youtu.be') {
|
if (urlp.hostname === 'youtu.be') {
|
||||||
const videoId = urlp.pathname.split('/')[1]
|
const videoId = urlp.pathname.split('/')[1]
|
||||||
const seek = encodeURIComponent(urlp.searchParams.get('t') ?? 0)
|
const t = urlp.searchParams.get('t') ?? '0'
|
||||||
|
const seek = encodeURIComponent(t.replace(/s$/, ''))
|
||||||
|
|
||||||
if (videoId) {
|
if (videoId) {
|
||||||
return {
|
return {
|
||||||
type: 'youtube_video',
|
type: 'youtube_video',
|
||||||
@@ -111,7 +113,8 @@ export function parseEmbedPlayerFromUrl(
|
|||||||
isShorts || isLive
|
isShorts || isLive
|
||||||
? shortOrLiveVideoId
|
? shortOrLiveVideoId
|
||||||
: (urlp.searchParams.get('v') as string)
|
: (urlp.searchParams.get('v') as string)
|
||||||
const seek = encodeURIComponent(urlp.searchParams.get('t') ?? 0)
|
const t = urlp.searchParams.get('t') ?? '0'
|
||||||
|
const seek = encodeURIComponent(t.replace(/s$/, ''))
|
||||||
|
|
||||||
if (videoId) {
|
if (videoId) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user