mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(embeds): add support to youtube shorts
This commit is contained in:
@@ -74,6 +74,8 @@ const YoutubeEmbed = ({ parsedUrl }: EmbedComponentProps) => {
|
||||
if (!videoId) {
|
||||
if (parsedUrl.host.includes('youtu.be')) {
|
||||
videoId = parsedUrl.pathname.substring(1);
|
||||
} else if (parsedUrl.pathname.includes('/shorts/')) {
|
||||
videoId = parsedUrl.pathname.split('/shorts/')[1];
|
||||
} else if (isInvidious) {
|
||||
if (parsedUrl.pathname.startsWith('/watch')) {
|
||||
videoId = parsedUrl.searchParams.get('v');
|
||||
|
||||
@@ -52,6 +52,8 @@ export const getHasThumbnail = (commentMediaInfo: CommentMediaInfo | undefined,
|
||||
const getYouTubeVideoId = (url: URL): string | null => {
|
||||
if (url.host.includes('youtu.be')) {
|
||||
return url.pathname.slice(1);
|
||||
} else if (url.pathname.includes('/shorts/')) {
|
||||
return url.pathname.split('/shorts/')[1].split('/')[0];
|
||||
} else if (url.searchParams.has('v')) {
|
||||
return url.searchParams.get('v');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user