You are here

function elf_url_external in External Links Filter 7.3

Same name and namespace in other branches
  1. 5.3 elf.module \elf_url_external()
  2. 6.3 elf.module \elf_url_external()

Test if a URL is external

Parameters

$url string:

1 call to elf_url_external()
elf_replace in ./elf.module
Hook_filter_info() process callback.

File

./elf.module, line 181
Adds an icon to external and mailto links.

Code

function elf_url_external($url) {
  global $base_url;
  static $pattern = NULL;

  // Statically store internal domains as a PCRE pattern.
  if (!$pattern) {
    $domains = array();
    foreach (array_merge(variable_get('elf_domains', array()), array(
      $base_url,
    )) as $domain) {
      $domains[] = preg_quote($domain, '#');
    }
    $pattern = '#^(' . str_replace('\\*', '.*', implode('|', $domains)) . ')#';
  }
  return preg_match($pattern, $url) ? FALSE : url_is_external($url);
}