diff --git a/all_test.go b/all_test.go index d2af6e2..27e9842 100644 --- a/all_test.go +++ b/all_test.go @@ -34,6 +34,11 @@ var uastrings = []struct { ua: "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)", expected: "Mozilla:5.0 Browser:Googlebot-2.1 Bot:true Mobile:true", }, + { + title: "GoogleBotEmulateMozilla", + ua: "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Safari/537.36", + expected: "Mozilla:5.0 Browser:Googlebot-2.1 Bot:true Mobile:false", + }, { title: "BingBot", ua: "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)", diff --git a/bot.go b/bot.go index acccd51..df732d4 100644 --- a/bot.go +++ b/bot.go @@ -22,6 +22,8 @@ func getFromSite(comment []string) string { idx := 2 if len(comment) < 3 { idx = 0 + } else if len(comment) == 4 { + idx = 3 } // Pick the site. @@ -34,7 +36,7 @@ func getFromSite(comment []string) string { // This is a large comment, usually the name will be in the previous // field of the comment. - return strings.TrimSpace(comment[1]) + return strings.TrimSpace(comment[idx-1]) } return "" } diff --git a/browser.go b/browser.go index c6a1d24..d9acc92 100644 --- a/browser.go +++ b/browser.go @@ -76,6 +76,13 @@ func (p *UserAgent) detectBrowser(sections []section) { } else { p.browser.Name = "Safari" } + // Its possible the google-bot emulates these now + for _, comment := range engine.comment { + if len(comment) > 5 && strings.HasPrefix(comment, "Googlebot") { + p.undecided = true + break + } + } } } else if engine.name == "Gecko" { name := sections[2].name