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

Commit 6fe362d

Browse files
delphinusmssola
authored andcommitted
Detect updated UA for Googlebot (#41)
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.
1 parent a2f39d5 commit 6fe362d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

all_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,15 @@ var uastrings = []struct {
2525
expected: "Mozilla:5.0 Browser:Googlebot-2.1 Bot:true Mobile:false",
2626
},
2727
{
28-
title: "GoogleBotSmartphone",
28+
title: "GoogleBotSmartphone (iPhone)",
2929
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)",
3030
expected: "Mozilla:5.0 Browser:Googlebot-2.1 Bot:true Mobile:true",
3131
},
32+
{
33+
title: "GoogleBotSmartphone (Android)",
34+
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)",
35+
expected: "Mozilla:5.0 Browser:Googlebot-2.1 Bot:true Mobile:true",
36+
},
3237
{
3338
title: "BingBot",
3439
ua: "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)",

operating_systems.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ func webkit(p *UserAgent, comment []string) {
8888
}
8989
if len(comment) > 3 {
9090
p.localization = comment[3]
91+
} else if len(comment) == 3 {
92+
_ = p.googleBot()
9193
}
9294
} else if len(comment) > 0 {
9395
if len(comment) > 3 {

0 commit comments

Comments
 (0)