Skip to content

Commit 705adf0

Browse files
committed
fix youtube video links missing params in dev branch
1 parent f0ad4f5 commit 705adf0

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/app/components/url-preview/ClientPreview.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff 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,

0 commit comments

Comments
 (0)