Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

(no description)

File Size: 220 lines (8 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

UriNormalizer:: (5 methods):
  normalize()
  isEquivalent()
  capitalizePercentEncoding()
  decodeUnreservedCharacters()
  __construct()


Class: UriNormalizer  - X-Ref

Provides methods to normalize and compare URIs.

normalize(UriInterface $uri, int $flags = self::PRESERVING_NORMALIZATIONS)   X-Ref
Returns a normalized URI.

The scheme and host component are already normalized to lowercase per PSR-7 UriInterface.
This methods adds additional normalizations that can be configured with the $flags parameter.

PSR-7 UriInterface cannot distinguish between an empty component and a missing component as
getQuery(), getFragment() etc. always return a string. This means the URIs "/?#" and "/" are
treated equivalent which is not necessarily true according to RFC 3986. But that difference
is highly uncommon in reality. So this potential normalization is implied in PSR-7 as well.

param: UriInterface $uri   The URI to normalize
param: int          $flags A bitmask of normalizations to apply, see constants

isEquivalent(UriInterface $uri1, UriInterface $uri2, int $normalizations = self::PRESERVING_NORMALIZATIONS)   X-Ref
Whether two URIs can be considered equivalent.

Both URIs are normalized automatically before comparison with the given $normalizations bitmask. The method also
accepts relative URI references and returns true when they are equivalent. This of course assumes they will be
resolved against the same base URI. If this is not the case, determination of equivalence or difference of
relative references does not mean anything.

param: UriInterface $uri1           An URI to compare
param: UriInterface $uri2           An URI to compare
param: int          $normalizations A bitmask of normalizations to apply, see constants

capitalizePercentEncoding(UriInterface $uri)   X-Ref
No description

decodeUnreservedCharacters(UriInterface $uri)   X-Ref
No description

__construct()   X-Ref
No description