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 {
7
7
8
8
const youtubeRegExp =
9
9
/ 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 =
11
11
/ 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 ] + ) | ) / ;
12
14
const youtubeListRegExp =
13
15
/ 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 ] + | ) ) / ;
14
16
@@ -31,6 +33,16 @@ export const parseYoutube = (url: string): YoutubeProps | undefined => {
31
33
} ;
32
34
}
33
35
}
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
+ }
34
46
{
35
47
const matches = url . match ( youtubeShortRegExp ) ;
36
48
if ( matches ) {
You can’t perform that action at this time.
0 commit comments