function LocalAwareRedirectResponseTrait::isLocal

Same name in other branches
  1. 9 core/lib/Drupal/Core/Routing/LocalAwareRedirectResponseTrait.php \Drupal\Core\Routing\LocalAwareRedirectResponseTrait::isLocal()
  2. 10 core/lib/Drupal/Core/Routing/LocalAwareRedirectResponseTrait.php \Drupal\Core\Routing\LocalAwareRedirectResponseTrait::isLocal()
  3. 11.x core/lib/Drupal/Core/Routing/LocalAwareRedirectResponseTrait.php \Drupal\Core\Routing\LocalAwareRedirectResponseTrait::isLocal()

Determines whether a path is local.

Parameters

string $url: The internal path or external URL being linked to, such as "node/34" or "http://example.com/foo".

Return value

bool TRUE or FALSE, where TRUE indicates a local path.

1 call to LocalAwareRedirectResponseTrait::isLocal()
TrustedRedirectResponse::isSafe in core/lib/Drupal/Core/Routing/TrustedRedirectResponse.php
Returns whether the URL is considered as safe to redirect to.

File

core/lib/Drupal/Core/Routing/LocalAwareRedirectResponseTrait.php, line 29

Class

LocalAwareRedirectResponseTrait
Provides a trait which ensures that a URL is safe to redirect to.

Namespace

Drupal\Core\Routing

Code

protected function isLocal($url) {
    return !UrlHelper::isExternal($url) || UrlHelper::externalIsLocal($url, $this->getRequestContext()
        ->getCompleteBaseUrl());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.