def parse_url(url)
      uri = URI(url)
      if URI.split(url)[3].nil?
        uri.port = uri.scheme == 'https' ? DEFAULT_HTTPS_PORT : DEFAULT_HTTP_PORT
      end

      raise ArgumentError, "URL #{url} has invalid scheme" unless uri.scheme =~ /^https?$/
      parsed_url = { ssl: uri.scheme == 'https', host: uri.host, port: uri.port }
      if uri.user || uri.password
        parsed_url[:username] = uri.user
        parsed_url[:password] = uri.password
      end

      parsed_url
    rescue URI::InvalidURIError => exc
      raise exc.class, "Invalid URL: #{url} (#{exc.message})"
    end
def parse_url(url)
      uri = URI(url)
      if URI.split(url)[3].nil?
        uri.port = uri.scheme == 'https' ? DEFAULT_HTTPS_PORT : DEFAULT_HTTP_PORT
      end

      raise ArgumentError, "URL #{url} has invalid scheme" unless uri.scheme =~ /^https?$/
      parsed_url = { ssl: uri.scheme == 'https', host: uri.host, port: uri.port }
      if uri.user || uri.password
        parsed_url[:username] = uri.user
        parsed_url[:password] = uri.password
      end

      parsed_url
    rescue URI::InvalidURIError => exc
      raise exc.class, "Invalid URL: #{url} (#{exc.message})"
    end
Parse a URL to determine hostname, port number, and whether or not SSL is used.
 @param url [String] URL to parse
 @return [Hash] { ssl: true/false, host: <String>, port: <Integer> }