Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve youtube and vimeo link-identifying regexps #683

Open
gadenbuie opened this issue Mar 31, 2022 · 1 comment
Open

Improve youtube and vimeo link-identifying regexps #683

gadenbuie opened this issue Mar 31, 2022 · 1 comment

Comments

@gadenbuie
Copy link
Member

gadenbuie commented Mar 31, 2022

The current regexps for identifying YouTube and Vimeo links are designed to find links that are known candidates. For example, the YT regexp is good for extracting the embed ID from a known probable YT link. They don't however, include some baseline checks such as checking that the link is an https? link. It would be unusual, but it's still possible that something not intended to be used as a YT link (a base64-encoded image, for example) could be picked out as a YT link.

const youtubeRegex = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/
const vimeoRegex = /(?:vimeo)\.com.*(?:videos|video|channels|)\/([\d]+)/i

Our docs state that the whole link should be used, so I think it'd be okay for us to add in ^http to the regexp. Alternatively, we could find a more robust regular expression.

@gadenbuie
Copy link
Member Author

Or we could check that src doesn't start with data:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant