Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Endpoint.php

function Endpoint::matchUrl

Tries to match a URL against the endpoint schemes.

Parameters

string $url: Media item URL.

Return value

bool TRUE if the URL matches against the endpoint schemes, otherwise FALSE.

File

core/modules/media/src/OEmbed/Endpoint.php, line 151

Class

Endpoint
Value object for oEmbed provider endpoints.

Namespace

Drupal\media\OEmbed

Code

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal