Skip to content

Commit

Permalink
TestAgent: removed duplicate code, thanks to Ujjwal Thaakar
Browse files Browse the repository at this point in the history
  • Loading branch information
temoto committed Jan 14, 2015
1 parent 2f12971 commit c51489e
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions robotstxt.go
Expand Up @@ -147,16 +147,8 @@ func (r *RobotsData) TestAgent(path, agent string) bool {
// Find a group of rules that applies to this agent
// From Google's spec:
// The user-agent is non-case-sensitive.
if g := r.FindGroup(agent); g != nil {
// Find a rule that applies to this url
if r := g.findRule(path); r != nil {
return r.allow
}
}

// From Google's spec:
// By default, there are no restrictions for crawling for the designated crawlers.
return true
g := r.FindGroup(agent)
return g.Test(path)
}

// From Google's spec:
Expand Down Expand Up @@ -195,7 +187,8 @@ func (g *Group) Test(path string) bool {
return r.allow
}

// When no rule applies, allow by default
// From Google's spec:
// By default, there are no restrictions for crawling for the designated crawlers.
return true
}

Expand Down

1 comment on commit c51489e

@ujjwalt
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @temoto

Please sign in to comment.