Issue #3222616 by phenaproxima, vsujeetkumar, labboy0276, hmendes, cilefen: YouTube PlayLists can't be added to Remote Video due to regex issue
parent
aea32e8a9f
commit
5a3a0abaf2
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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'));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue