File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,10 @@ export interface YoutubeProps {
77
88const youtubeRegExp =
99 / h t t p s ? : \/ \/ (?: w w w \. | ) y o u t u b e \. c o m \/ w a t c h \? ( (?: [ ^ \s ] + & | ) v = ( [ a - z A - Z \d _ - ] + ) (?: & [ ^ \s ] + | ) ) / ;
10- const youtubeShortRegExp =
10+ const youtubeDotBeRegExp =
1111 / h t t p s ? : \/ \/ y o u t u \. b e \/ ( [ a - z A - Z \d _ - ] + ) (?: \? ( [ ^ \s ] { 0 , 100 } ) | ) / ;
12+ const youtubeShortRegExp =
13+ / h t t p s ? : \/ \/ (?: w w w \. | ) y o u t u b e \. c o m \/ s h o r t s \/ ( [ a - z A - Z \d _ - ] + ) (?: \? ( [ ^ \s ] + ) | ) / ;
1214const youtubeListRegExp =
1315 / h t t p s ? : \/ \/ (?: w w w \. | ) y o u t u b e \. c o m \/ p l a y l i s t \? ( (?: [ ^ \s ] + & | ) l i s t = ( [ a - z A - Z \d _ - ] + ) (?: & [ ^ \s ] + | ) ) / ;
1416
@@ -31,6 +33,16 @@ export const parseYoutube = (url: string): YoutubeProps | undefined => {
3133 } ;
3234 }
3335 }
36+ {
37+ const matches = url . match ( youtubeDotBeRegExp ) ;
38+ if ( matches ) {
39+ const [ , videoId ] = matches ;
40+ return {
41+ videoId,
42+ params : new URLSearchParams ( "autoplay=0" ) ,
43+ } ;
44+ }
45+ }
3446 {
3547 const matches = url . match ( youtubeShortRegExp ) ;
3648 if ( matches ) {
You can’t perform that action at this time.
0 commit comments