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
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ public function supportsDiscovery() {
  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;
      }
+27 −0
Original line number Diff line number Diff line
<?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'));
  }

}