Investigate using flip-flop operator? #1

Open
opened 2024-12-25 12:34:08 +00:00 by dkam · 1 comment
Owner

probot/lib/probot.rb Lines 82 to 88 in 45c1b001cd
if data.agent?
if subsequent_agent
@current_agents << data.value
else
@current_agents = [data.value]
subsequent_agent = true
end

https://git.booko.info/dkam/probot/src/commit/45c1b001cd499f0517298aa65bc28942b2277e8b/lib/probot.rb#L82-L88
Author
Owner
       if data.agent?
        # Flip-flop: ON when we see User-agent, OFF when we see anything else
        if data.agent? .. !data.agent?
          @current_agents << data.value
        else
          @current_agents = [data.value]
        end

        @current_agents.each { |agent| rules[agent] ||= {"disallow" => [], "allow" => [], "crawl_delay" => 0} }
        next
      end
```ruby if data.agent? # Flip-flop: ON when we see User-agent, OFF when we see anything else if data.agent? .. !data.agent? @current_agents << data.value else @current_agents = [data.value] end @current_agents.each { |agent| rules[agent] ||= {"disallow" => [], "allow" => [], "crawl_delay" => 0} } next end ```
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dkam/probot#1