Back to Uri class

Method isInternal

public static bool
isInternal
(mixed $url)
Checks if the supplied URL is internal
Parameters
  • string $url The URL to check.
Returns
  • bool True if Internal.
Since
  • 1.7.0
Class: Uri
Project: Joomla

Method isInternal - Source code

/**
 * Checks if the supplied URL is internal
 *
 * @param   string  $url  The URL to check.
 *
 * @return  boolean  True if Internal.
 *
 * @since   1.7.0
 */
public static function isInternal($url)
{
    $url = str_replace('\\', '/', $url);
    $uri = static::getInstance($url);
    $base = $uri->toString(array('scheme', 'host', 'port', 'path'));
    $host = $uri->toString(array('scheme', 'host', 'port'));
    // @see UriTest
    if (empty($host) && strpos($uri->path, 'index.php') === 0 || !empty($host) && preg_match('#' . preg_quote(static::base(), '#') . '#', $base) || !empty($host) && $host === static::getInstance(static::base())->host && strpos($uri->path, 'index.php') !== false || !empty($host) && $base === $host && preg_match('#' . preg_quote($base, '#') . '#', static::base())) {
        return true;
    }
    return false;
}