protected static function normalizePath(string $path): string
    {
        if (!static::isValidPath($path)) {
            $message = sprintf('Invalid URI path: %s', $path);
            throw new DomainException($message);
        }

        $path = static::removeDotSegments($path);

        return static::encodePath(static::decode($path, static::UNRESERVED_SET));
    }