refactor: build the issue report from loaded data
Issues loads the entries, rules, redirects, robots row and noindex addresses, then issuesOf builds the report and blockedNoindex checks the addresses against robots.txt, so the report's rules can be unit-tested without a database. No behaviour change.
This commit is contained in:
@@ -221,11 +221,17 @@ func (s *Service) BlockedNoindex(db *gorm.DB, content string, bots models.BotSwi
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.blockedNoindex(urls, content, bots), nil
|
||||
}
|
||||
|
||||
// blockedNoindex lists the addresses of urls Googlebot may not fetch under
|
||||
// the production file composed from content and bots.
|
||||
func (s *Service) blockedNoindex(urls []string, content string, bots models.BotSwitches) []string {
|
||||
var out []string
|
||||
for _, u := range urls {
|
||||
if !s.TestRobots(content, bots, "Googlebot", u).Allowed {
|
||||
out = append(out, u)
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
return out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user