You are here

function _oembedcore_get_host in oEmbed 6.0

A utility function to get the base domain from a url.

Parameters

string $uri: The uri to get the domain form

Return value

string The domain or NULL

2 calls to _oembedcore_get_host()
oembedcore_get_provider in ./oembedcore.module
Returns the provider for a url.
oembedcore_providers in ./oembedcore.module
Returns all the registered providers, or the providers for a specific host.

File

./oembedcore.module, line 159
Core functionality for oEmbed

Code

function _oembedcore_get_host($uri) {
  $matches = array();
  if (preg_match('/^https?\\:\\/\\/([^\\/]+)/', $uri, $matches)) {
    $matches = explode('.', $matches[1]);
    $match_count = count($matches);
    if ($match_count > 1) {
      return $matches[$match_count - 2] . '.' . $matches[$match_count - 1];
    }
    else {
      return $matches[0];
    }
  }
  return NULL;
}