function file_stream_wrapper_uri_normalize in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/includes/file.inc \file_stream_wrapper_uri_normalize()
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
5 calls to file_stream_wrapper_uri_normalize()
- file_build_uri in core/
includes/ file.inc - Constructs a URI to Drupal's default files location given a relative path.
- file_save_htaccess in core/
includes/ file.inc - Creates a .htaccess file in the given directory.
- file_scan_directory in core/
includes/ file.inc - Finds all files that match a given mask in a given directory.
- file_unmanaged_copy in core/
includes/ file.inc - Copies a file to a new location without invoking the file API.
- ImageStyle::buildUrl in core/
modules/ image/ src/ Entity/ ImageStyle.php - Returns the URL of this image derivative for an original image path or URI.
File
- core/
includes/ file.inc, line 158 - 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;
}