1. drupal
    1. 8
    2. 7
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 "://".


$uri String reference containing the URI to normalize.

Return value

The normalized URI.

Related topics

▾ 5 functions call file_stream_wrapper_uri_normalize()

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


includes/, line 279

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;