2
0

Add support for Applebot

This commit is contained in:
Milos Mileusnic
2020-08-28 15:54:34 +02:00
parent 2aaeb7ae65
commit 726a5d1b2d
2 changed files with 10 additions and 1 deletions
+8
View File
@@ -51,6 +51,7 @@ const (
Googlebot = "Googlebot"
Twitterbot = "Twitterbot"
FacebookExternalHit = "facebookexternalhit"
Applebot = "Applebot"
)
// Parse user agent string returning UserAgent struct
@@ -128,6 +129,13 @@ func Parse(userAgent string) UserAgent {
ua.Bot = true
ua.Mobile = tokens.existsAny("Mobile", "Mobile Safari")
case tokens.exists("Applebot"):
ua.Name = Applebot
ua.Version = tokens[Applebot]
ua.Bot = true
ua.Mobile = tokens.existsAny("Mobile", "Mobile Safari")
ua.OS = ""
case tokens["Opera Mini"] != "":
ua.Name = OperaMini
ua.Version = tokens[OperaMini]
+2 -1
View File
@@ -61,7 +61,8 @@ func TestParse(t *testing.T) {
// Bots
{"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)", ua.Googlebot, "2.1", "mobile", "Android"},
{"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)", ua.Googlebot, "2.1", "bot", ""},
{"Twitterbot/1.0", ua.Twitterbot, "1.0", "bot", ""},
{"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15 (Applebot/0.1; +http://www.apple.com/go/applebot)", "Applebot", "0.1", "bot", ""},
{"Twitterbot/1.0", ua.Twitterbot, "1.0", ua.Applebot, ""},
{"facebookexternalhit/1.1", ua.FacebookExternalHit, "1.1", "bot", ""},
// other