Skip to content

Commit

Permalink
fix: mark nocookie youtube url as valid when parsing html (#4883)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasHirt authored Feb 19, 2024
1 parent 5a4c3ba commit 099e10d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions 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
@@ -1,4 +1,4 @@
export const YOUTUBE_REGEX = /^(https?:\/\/)?(www\.|music\.)?(youtube\.com|youtu\.be)\/(?!channel\/)(?!@)(.+)?$/
export const YOUTUBE_REGEX = /^(https?:\/\/)?(www\.|music\.)?(youtube\.com|youtu\.be|youtube-nocookie\.com)\/(?!channel\/)(?!@)(.+)?$/
export const YOUTUBE_REGEX_GLOBAL = /^(https?:\/\/)?(www\.|music\.)?(youtube\.com|youtu\.be)\/(?!channel\/)(?!@)(.+)?$/g

export const isValidYoutubeUrl = (url: string) => {
Expand Down
28 changes: 28 additions & 0 deletions tests/cypress/integration/extensions/youtube.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,32 @@ describe('extension-youtube', () => {
getEditorEl()?.remove()
})
})

it('when nocookie youtube url is passed, still outputs html with iframe with the url', () => {
editor = new Editor({
element: createEditorEl(),
extensions: [
Document,
Text,
Paragraph,
Youtube,
],
content: {
type: 'doc',
content: [
{
type: 'youtube',
attrs: {
src: 'https://www.youtube-nocookie.com/embed/testvideoid',
},
},
],
},
})

expect(editor.getHTML()).to.include('https://www.youtube-nocookie.com/embed/testvideoid')

editor?.destroy()
getEditorEl()?.remove()
})
})

0 comments on commit 099e10d

Please sign in to comment.