file_stream_wrapper_uri_normalize
- Versions
- 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 all occurrences of the wrapper's directory path
- 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
Code
includes/file.inc, line 209
<?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);
// Remove all occurrences of the wrapper's directory path.
$directory_path = file_stream_wrapper_get_instance_by_scheme($scheme)->getDirectoryPath();
$target = str_replace($directory_path, '', $target);
// Trim trailing slashes from target.
$target = rtrim($target, '/');
// Trim erroneous leading slashes from target.
$uri = $scheme . '://' . ltrim($target, '/');
}
return $uri;
}
?>Login or register to post comments 