121 if ($flags & self::CAPITALIZE_PERCENT_ENCODING) {
122 $uri = self::capitalizePercentEncoding($uri);
125 if ($flags & self::DECODE_UNRESERVED_CHARACTERS) {
126 $uri = self::decodeUnreservedCharacters($uri);
129 if ($flags & self::CONVERT_EMPTY_PATH && $uri->
getPath() ===
'' &&
135 if ($flags & self::REMOVE_DEFAULT_HOST && $uri->
getScheme() ===
'file' && $uri->
getHost() ===
'localhost') {
147 if ($flags & self::REMOVE_DUPLICATE_SLASHES) {
151 if ($flags & self::SORT_QUERY_PARAMETERS && $uri->
getQuery() !==
'') {
152 $queryKeyValues = explode(
'&', $uri->
getQuery());
153 sort($queryKeyValues);
154 $uri = $uri->
withQuery(implode(
'&', $queryKeyValues));
177 return (
string) self::normalize($uri1, $normalizations) === (
string) self::normalize($uri2, $normalizations);
182 $regex =
'/(?:%[A-Fa-f0-9]{2})++/';
184 $callback =
function (
array $match) {
185 return strtoupper($match[0]);
190 preg_replace_callback($regex, $callback, $uri->
getPath())
192 preg_replace_callback($regex, $callback, $uri->
getQuery())
198 $regex =
'/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i';
200 $callback =
function (
array $match) {
201 return rawurldecode($match[0]);
206 preg_replace_callback($regex, $callback, $uri->
getPath())
208 preg_replace_callback($regex, $callback, $uri->
getQuery())
const REMOVE_DEFAULT_HOST
Removes the default host of the given URI scheme from the URI.
getHost()
Retrieve the host component of the URI.
const REMOVE_DEFAULT_PORT
Removes the default port of the given URI scheme from the URI.
const CAPITALIZE_PERCENT_ENCODING
All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capit...
static removeDotSegments($path)
Removes dot segments from a path and returns the new path.
Value object representing a URI.
static decodeUnreservedCharacters(UriInterface $uri)
const REMOVE_DUPLICATE_SLASHES
Paths which include two or more adjacent slashes are converted to one.
withQuery($query)
Return an instance with the specified query string.
getScheme()
Retrieve the scheme component of the URI.
withPath($path)
Return an instance with the specified path.
const SORT_QUERY_PARAMETERS
Sort query parameters with their values in alphabetical order.
const CONVERT_EMPTY_PATH
Converts the empty path to "/" for http and https URIs.
static isRelativePathReference(UriInterface $uri)
Whether the URI is a relative-path reference.
getPath()
Retrieve the path component of the URI.
withHost($host)
Return an instance with the specified host.
getPort()
Retrieve the port component of the URI.
withPort($port)
Return an instance with the specified port.
const PRESERVING_NORMALIZATIONS
Default normalizations which only include the ones that preserve semantics.
Create styles array
The data for the language used.
const REMOVE_DOT_SEGMENTS
Removes unnecessary dot-segments.
static normalize(UriInterface $uri, $flags=self::PRESERVING_NORMALIZATIONS)
Returns a normalized URI.
static isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations=self::PRESERVING_NORMALIZATIONS)
Whether two URIs can be considered equivalent.
static isDefaultPort(UriInterface $uri)
Whether the URI has the default port of the current scheme.
Provides methods to normalize and compare URIs.
getQuery()
Retrieve the query string of the URI.
const DECODE_UNRESERVED_CHARACTERS
Decodes percent-encoded octets of unreserved characters.
static capitalizePercentEncoding(UriInterface $uri)