You are here

protected function StaticGenerator::makeExternalUrlLocal in Tome 8

Makes external URLs local if their hostname is the current hostname.

Parameters

string $path: A path.

Return value

string A possibly transformed path.

3 calls to StaticGenerator::makeExternalUrlLocal()
StaticGenerator::exportPaths in modules/tome_static/src/StaticGenerator.php
Exports multiple paths.
StaticGenerator::filterInvokePaths in modules/tome_static/src/StaticGenerator.php
Filters invoke paths to remove any external or cached paths.
StaticGenerator::requestPath in modules/tome_static/src/StaticGenerator.php
Requests and exports a given path.

File

modules/tome_static/src/StaticGenerator.php, line 316

Class

StaticGenerator
Handles static site generation.

Namespace

Drupal\tome_static

Code

protected function makeExternalUrlLocal($path) {
  $components = parse_url($path);
  if (UrlHelper::isExternal($path) && isset($components['host']) && UrlHelper::externalIsLocal($path, $this->currentRequest
    ->getSchemeAndHttpHost())) {
    $path = $components['path'];
    if (!empty($components['query'])) {
      $path .= '?' . $components['query'];
    }
  }
  return $path;
}