Skip to content

Commit

Permalink
feat(extension/youtube): Allow youtube shorts urls to be embedded
Browse files Browse the repository at this point in the history
Youtube uses /shorts/ for their shorts video. The /embed url works with these id's, the regex did not support them though.

This updates the videoId regex to also support the /shorts/ urls.
  • Loading branch information
arendjantetteroo authored Sep 29, 2023
1 parent a78c3a1 commit 4d79cb8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/extension-youtube/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const getEmbedUrlFromYoutubeUrl = (options: GetEmbedUrlOptions) => {
return `${getYoutubeEmbedUrl(nocookie)}${id}`
}

const videoIdRegex = /v=([-\w]+)/gm
const videoIdRegex = /(?:v=|shorts\/)([-\w]+)/gm
const matches = videoIdRegex.exec(url)

if (!matches || !matches[1]) {
Expand Down

0 comments on commit 4d79cb8

Please sign in to comment.