Issue #3222616 by phenaproxima, vsujeetkumar, labboy0276, hmendes, cilefen: YouTube PlayLists can't be added to Remote Video due to regex issue

merge-requests/845/merge
catch 2021-08-05 08:31:38 +01:00
parent aea32e8a9f
commit 5a3a0abaf2
2 changed files with 28 additions and 1 deletions

View File

@ -151,7 +151,7 @@ class Endpoint {
public function matchUrl($url) {
foreach ($this->getSchemes() as $scheme) {
// Convert scheme into a valid regular expression.
$regexp = str_replace(['.', '*'], ['\.', '.*'], $scheme);
$regexp = str_replace(['.', '*', '?'], ['\.', '.*', '\?'], $scheme);
if (preg_match("|^$regexp$|", $url)) {
return TRUE;
}

View File

@ -0,0 +1,27 @@
<?php
namespace Drupal\Tests\media\Unit;
use Drupal\media\OEmbed\Endpoint;
use Drupal\Tests\UnitTestCase;
/**
* @coversDefaultClass \Drupal\media\OEmbed\Endpoint
*
* @group media
*/
class EndpointTest extends UnitTestCase {
/**
* @covers ::matchUrl
*/
public function testMatchUrl(): void {
$endpoint = new Endpoint(
'https://www.youtube.com/oembed',
$this->createMock('\Drupal\media\OEmbed\Provider'),
['https://*.youtube.com/playlist?list=*']
);
$this->assertTrue($endpoint->matchUrl('https://www.youtube.com/playlist?list=aBc-EzAs123'));
}
}