Browse Source

Fixed invalid youtube url in configuration.

Kamil Piechaczek 7 years ago
parent
commit
bcf21c11c5

+ 4 - 4
packages/ckeditor5-media-embed/src/mediaembedediting.js

@@ -73,10 +73,10 @@ export default class MediaEmbedEditing extends Plugin {
 				{
 					name: 'youtube',
 					url: [
-						/^youtube\.com\/watch\?v=(\w+)/,
-						/^youtube\.com\/v\/(\w+)/,
-						/^youtube\.com\/embed\/(\w+)/,
-						/^youtu\.be\/(\w+)/
+						/^youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)/,
+						/^youtube\.com\/v\/([a-zA-Z0-9_-]+)/,
+						/^youtube\.com\/embed\/([a-zA-Z0-9_-]+)/,
+						/^youtu\.be\/([a-zA-Z0-9_-]+)/
 					],
 					html: match => {
 						const id = match.slice( -1 );

+ 12 - 12
packages/ckeditor5-media-embed/tests/mediaembedediting.js

@@ -201,23 +201,23 @@ describe( 'MediaEmbedEditing', () => {
 
 						it( 'upcasts the URL (youtube)', () => {
 							testMediaUpcast( [
-								'https://www.youtube.com/watch?v=foo',
-								'www.youtube.com/watch?v=foo',
-								'youtube.com/watch?v=foo',
+								'https://www.youtube.com/watch?v=f-oo',
+								'www.youtube.com/watch?v=f-oo',
+								'youtube.com/watch?v=f-oo',
 
-								'https://www.youtube.com/v/foo',
-								'www.youtube.com/v/foo',
-								'youtube.com/v/foo',
+								'https://www.youtube.com/v/f-oo',
+								'www.youtube.com/v/f-oo',
+								'youtube.com/v/f-oo',
 
-								'https://www.youtube.com/embed/foo',
-								'www.youtube.com/embed/foo',
-								'youtube.com/embed/foo',
+								'https://www.youtube.com/embed/f-oo',
+								'www.youtube.com/embed/f-oo',
+								'youtube.com/embed/f-oo',
 
-								'https://youtu.be/foo',
-								'youtu.be/foo'
+								'https://youtu.be/f-oo',
+								'youtu.be/f-oo'
 							],
 							'<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 56.2493%;">' +
-								'<iframe src="https://www.youtube.com/embed/foo" ' +
+								'<iframe src="https://www.youtube.com/embed/f-oo" ' +
 									'style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" ' +
 									'frameborder="0" allow="autoplay; encrypted-media" allowfullscreen="">' +
 								'</iframe>' +