file_stream_wrapper_uri_normalize

  1. drupal
    1. 8
    2. 7
Versions
8 – 7 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

$uri String reference containing the URI to normalize.

Return value

The normalized URI.

Related topics

▾ 6 functions call file_stream_wrapper_uri_normalize()

file_build_uri in includes/file.inc
Given a relative path, construct a URI into Drupal's default files location.
file_create_htaccess in includes/file.inc
Creates an .htaccess file in the given directory.
file_scan_directory in includes/file.inc
Finds all files that match a given mask in a given directory.
file_unmanaged_copy in includes/file.inc
Copies a file to a new location without invoking the file API.
system_update_7061 in modules/system/system.install
Migrate upload.module data to the newly created file field.
user_save in modules/user/user.module
Save changes to a user account or add a new user.

Code

includes/file.inc, line 279

<?php
function file_stream_wrapper_uri_normalize($uri) {
  $scheme = file_uri_scheme($uri);

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

    if ($target !== FALSE) {
      $uri = $scheme . '://' . $target;
    }
  }
  else {
    // The default scheme is file://
    $url = 'file://' . $uri;
  }
  return $uri;
}
?>