Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Commit

Permalink
Detect updated UA for Googlebot (#41)
Browse files Browse the repository at this point in the history
Updated user agent for Googlebot

The new user agent has Android instead of iPhone. This patch adds the detection by calling the p.googleBot() method accordingly.
  • Loading branch information
delphinus authored and mssola committed Nov 30, 2017
1 parent a2f39d5 commit 6fe362d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ var uastrings = []struct {
expected: "Mozilla:5.0 Browser:Googlebot-2.1 Bot:true Mobile:false",
},
{
title: "GoogleBotSmartphone",
title: "GoogleBotSmartphone (iPhone)",
ua: "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",
expected: "Mozilla:5.0 Browser:Googlebot-2.1 Bot:true Mobile:true",
},
{
title: "GoogleBotSmartphone (Android)",
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: "BingBot",
ua: "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)",
Expand Down
2 changes: 2 additions & 0 deletions operating_systems.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ func webkit(p *UserAgent, comment []string) {
}
if len(comment) > 3 {
p.localization = comment[3]
} else if len(comment) == 3 {
_ = p.googleBot()
}
} else if len(comment) > 0 {
if len(comment) > 3 {
Expand Down

0 comments on commit 6fe362d

Please sign in to comment.