diff --git a/all_test.go b/all_test.go index d2af6e2..9af0b29 100644 --- a/all_test.go +++ b/all_test.go @@ -89,6 +89,16 @@ var uastrings = []struct { ua: "Mozilla/5.0 (compatible; AhrefsBot/4.0; +http://ahrefs.com/robot/)", expected: "Mozilla:5.0 Browser:AhrefsBot-4.0 Bot:true Mobile:false", }, + { + title: "AdsBotGoogle", + ua: "AdsBot-Google (+http://www.google.com/adsbot.html)", + expected: "Browser:AdsBot-Google Bot:true Mobile:false", + }, + { + title: "AdsBotGoogleMobile", + ua: "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1 (compatible; AdsBot-Google-Mobile; +http://www.google.com/mobile/adsbot.html)", + expected: "Mozilla:5.0 Browser:AdsBot-Google-Mobile Bot:true Mobile:true", + }, // Internet Explorer { diff --git a/bot.go b/bot.go index acccd51..8d53ec1 100644 --- a/bot.go +++ b/bot.go @@ -43,8 +43,9 @@ func getFromSite(comment []string) string { // mobile bot. This function also modifies some attributes in the receiver // accordingly. func (p *UserAgent) googleBot() bool { - // This is a hackish way to detect Google's mobile bot. - if strings.Index(p.ua, "Googlebot") != -1 { + // This is a hackish way to detect Google's mobile bot (Googlebot, AdsBot-Google-Mobile, etc.). + // See https://support.google.com/webmasters/answer/1061943 + if strings.Index(p.ua, "Google") != -1 { p.platform = "" p.undecided = true }