authorization_header_for_url

in lib/crawler/http_header_service.rb [68:88]


    def authorization_header_for_url(url) 
      raise ArgumentError, 'Need a Crawler URL object!' unless url.is_a?(Crawler::Data::URL)

      match = auth&.find { |item| item.fetch('domain') == url.site }

      value =
        case match&.fetch('type')
        when AuthTypes::BASIC
          "Basic #{Base64.strict_encode64("
        when AuthTypes::RAW
          match.fetch('header')
        end

      return unless value

      {
        type: match&.fetch('type'),
        value:
      }
    end