You are here

public function StreamWrapperManager::normalizeUri in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php \Drupal\Core\StreamWrapper\StreamWrapperManager::normalizeUri()

Normalizes a URI by making it syntactically correct.

A stream is referenced as "scheme://target".

The following actions are taken:

  • Remove trailing slashes from target
  • Trim erroneous leading slashes from target. e.g. ":///" becomes "://".

Parameters

string $uri: String reference containing the URI to normalize.

Return value

string The normalized URI.

Overrides StreamWrapperManagerInterface::normalizeUri

File

core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php, line 238

Class

StreamWrapperManager
Provides a StreamWrapper manager.

Namespace

Drupal\Core\StreamWrapper

Code

public function normalizeUri($uri) {
  $scheme = $this
    ->getScheme($uri);
  if ($this
    ->isValidScheme($scheme)) {
    $target = $this
      ->getTarget($uri);
    if ($target !== FALSE) {
      $uri = $scheme . '://' . $target;
    }
  }
  return $uri;
}