protected function enforceScheme(Uri $uri)
    {
        $path = $uri->getPath();
        if (strpos($path, '/') !== false) {
            list($host, $path) = explode('/', $path, 2);
            $path = '/' . $path;
        } else {
            $host = $path;
            $path = '';
        }

        // We have nothing to do if we have no host
        if (!$host) {
            return;
        }

        $uri->setScheme($this->enforcedScheme)
            ->setHost($host)
            ->setPath($path);
    }