file_stream_wrapper_uri_normalize

file_stream_wrapper_uri_normalize($uri)

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.

Related topics

File interface
Common file handling functions.

File

core/includes/file.inc, line 143
API for handling file uploads and server file management.

Code

function file_stream_wrapper_uri_normalize($uri) {
  $scheme = \Drupal::service('file_system')->uriScheme($uri);

  if (file_stream_wrapper_valid_scheme($scheme)) {
    $target = file_uri_target($uri);

    if ($target !== FALSE) {
      $uri = $scheme . '://' . $target;
    }
  }

  return $uri;
}
doc_Drupal
2016-10-29 09:14:16
Comments
Leave a Comment

Please login to continue.