File tree Expand file tree Collapse file tree
src/app/components/url-preview Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ function parseYoutubeLink(url: string): YoutubeLink | null {
166166 if ( url . includes ( 'youtu.be' ) ) {
167167 const split = path . split ( '?' ) ;
168168 [ videoId ] = split ;
169- params = split [ 1 ] . split ( '&' ) ;
169+ params = split [ 1 ] ? .split ( '&' ) ?? undefined ;
170170 } else {
171171 params = path . split ( '?' ) [ 1 ] . split ( '&' ) ;
172172 videoId = params . find ( ( s ) => s . startsWith ( 'v=' ) , params ) ?. split ( 'v=' ) [ 1 ] ;
@@ -175,8 +175,10 @@ function parseYoutubeLink(url: string): YoutubeLink | null {
175175 if ( ! videoId ) return null ;
176176
177177 // playlist is not used for the embed, it can be appended as is
178- const playlist = params . find ( ( s ) => s . startsWith ( 'list=' ) , params ) ;
179- const timestamp = params . find ( ( s ) => s . startsWith ( 't=' ) , params ) ?. split ( 't=' ) [ 1 ] ;
178+ const playlist = params ? params . find ( ( s ) => s . startsWith ( 'list=' ) , params ) : undefined ;
179+ const timestamp = params
180+ ? params . find ( ( s ) => s . startsWith ( 't=' ) , params ) ?. split ( 't=' ) [ 1 ]
181+ : undefined ;
180182
181183 return {
182184 videoId,
You can’t perform that action at this time.
0 commit comments