public function Endpoint::matchUrl in Drupal 10
Same name and namespace in other branches
- 8 core/modules/media/src/OEmbed/Endpoint.php \Drupal\media\OEmbed\Endpoint::matchUrl()
- 9 core/modules/media/src/OEmbed/Endpoint.php \Drupal\media\OEmbed\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\OEmbedCode
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;
}