mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-27 14:59:27 +08:00
fix(extension-youtube) change regex to disallow non-youtube domains
This commit is contained in:
parent
7debf2baf0
commit
1bd714a408
@ -1,5 +1,5 @@
|
||||
export const YOUTUBE_REGEX = /^(https?:\/\/)?(www\.|music\.)?(youtube\.com|youtu\.be)(?!.*\/channel\/)(?!\/@)(.+)?$/
|
||||
export const YOUTUBE_REGEX_GLOBAL = /^(https?:\/\/)?(www\.|music\.)?(youtube\.com|youtu\.be)(?!.*\/channel\/)(?!\/@)(.+)?$/g
|
||||
export const YOUTUBE_REGEX = /^(https?:\/\/)?(www\.|music\.)?(youtube\.com|youtu\.be)\/(?!channel\/)(?!@)(.+)?$/
|
||||
export const YOUTUBE_REGEX_GLOBAL = /^(https?:\/\/)?(www\.|music\.)?(youtube\.com|youtu\.be)\/(?!channel\/)(?!@)(.+)?$/g
|
||||
|
||||
export const isValidYoutubeUrl = (url: string) => {
|
||||
return url.match(YOUTUBE_REGEX)
|
||||
|
@ -25,6 +25,7 @@ describe('extension-youtube', () => {
|
||||
// eslint-disable-next-line no-script-url
|
||||
'javascript:alert(window.origin)//embed/',
|
||||
'https://youtube.google.com/embed/fdsafsdf',
|
||||
'https://youtube.com.bad/embed'
|
||||
]
|
||||
|
||||
invalidUrls.forEach(url => {
|
||||
|
Loading…
Reference in New Issue
Block a user