user_agent
user_agent copied to clipboard
YandexBot is not detected as a bot on iPhone.
There are several 'User-Agent' kinds of 'YandexBot': https://user-agents.net/bots/yandexbot
The following kind is not detected as a bot: https://user-agents.net/string/mozilla-5-0-iphone-cpu-iphone-os-8-1-like-mac-os-x-applewebkit-600-1-4-khtml-like-gecko-version-8-0-mobile-12b411-safari-600-1-4-compatible-yandexbot-3-0-http-yandex-com-bots
Steps to reproduce the problem: var ua user_agent.UserAgent userAgent := "Mozilla/5.0 (iPhone; CPU iPhone OS 8_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B411 Safari/600.1.4 (compatible; YandexBot/3.0; +http://yandex.com/bots)" // Parse a User-Agent inners. ua.Parse(userAgent) // Check either a bot or not. ua.Bot() // == false
Expected result: ua.Bot() // == true
Verified solution: `
diff --git a/CHANGELOG.md b/CHANGELOG.md
- Fix detection of Firefox on iPad.
- Fix detection of Linux ARM-based Android.
- Add detection of Chromium Edge on Windows. +- Add detection of YandexBot on iPhone.
diff --git a/bot.go b/bot.go
-// Returns true if the info that we currently have corresponds to the Google +// Returns true if the info that we currently have corresponds to the Google or Yandex -func (p *UserAgent) googleOrBingBot() bool { +func (p *UserAgent) googleOrBingBotOrYandex() bool { // This is a hackish way to detect // Google's mobile bot (Googlebot, AdsBot-Google-Mobile, etc.) // (See https://support.google.com/webmasters/answer/1061943) // and Bing's mobile bot // (See https://www.bing.com/webmaster/help/which-crawlers-does-bing-use-8c184ec0)
-
if strings.Index(p.ua, "Google") != -1 || strings.Index(p.ua, "bingbot") != -1 {
-
// and Yandex's mobile bot
-
// (See https://yandex.ru/support/webmaster/robot-workings/check-yandex-robots.html)
-
if strings.Index(p.ua, "Google") != -1 || strings.Index(p.ua, "bingbot") != -1 || strings.Index(p.ua, "Yandex") != -1 {
diff --git a/operating_systems.go b/operating_systems.go
-
_ = p.googleOrBingBot()
-
_ = p.googleOrBingBotOrYandex()
-
if !p.googleOrBingBot() && !p.iMessagePreview() {
-
if !p.googleOrBingBotOrYandex() && !p.iMessagePreview() {
`