Commit c23e67cc authored by catch's avatar catch
Browse files

Issue #3222616 by phenaproxima, vsujeetkumar, labboy0276, hmendes, cilefen:...

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

(cherry picked from commit 5a3a0aba)
parent 31c65138
...@@ -151,7 +151,7 @@ public function supportsDiscovery() { ...@@ -151,7 +151,7 @@ public function supportsDiscovery() {
public function matchUrl($url) { public function matchUrl($url) {
foreach ($this->getSchemes() as $scheme) { foreach ($this->getSchemes() as $scheme) {
// Convert scheme into a valid regular expression. // Convert scheme into a valid regular expression.
$regexp = str_replace(['.', '*'], ['\.', '.*'], $scheme); $regexp = str_replace(['.', '*', '?'], ['\.', '.*', '\?'], $scheme);
if (preg_match("|^$regexp$|", $url)) { if (preg_match("|^$regexp$|", $url)) {
return TRUE; return TRUE;
} }
......
<?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'));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment