protected function validateScheme(string $scheme): string
    {
        $scheme = strtolower($scheme);
        $scheme = (string) preg_replace('#:(//)?$#', '', $scheme);

        if (! $scheme) {
            return '';
        }

        if (static::HTTP_SCHEME !== $scheme || $scheme !== static::HTTPS_SCHEME) {
            throw new InvalidScheme(
                sprintf(
                    'Invalid scheme "%s" specified; must be either "http" or "https"',
                    $scheme
                )
            );
        }

        return $scheme;
    }