Skip to content

Commit

Permalink
Adds support for Applebot
Browse files Browse the repository at this point in the history
  • Loading branch information
donatj committed Sep 1, 2020
1 parent b355111 commit e159493
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/UserAgentParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function parse_user_agent( $u_agent = null ) {

preg_match_all('%(?P<browser>Camino|Kindle(\ Fire)?|Firefox|Iceweasel|IceCat|Safari|MSIE|Trident|AppleWebKit|
TizenBrowser|(?:Headless)?Chrome|YaBrowser|Vivaldi|IEMobile|Opera|OPR|Silk|Midori|Edge|Edg|CriOS|UCBrowser|Puffin|OculusBrowser|SamsungBrowser|
Baiduspider|Googlebot|YandexBot|bingbot|Lynx|Version|Wget|curl|
Baiduspider|Applebot|Googlebot|YandexBot|bingbot|Lynx|Version|Wget|curl|
Valve\ Steam\ Tenfoot|
NintendoBrowser|PLAYSTATION\ (\d|Vita)+)
(?:\)?;?)
Expand Down Expand Up @@ -147,7 +147,7 @@ function parse_user_agent( $u_agent = null ) {
}
}
}
} elseif( $find(array( 'IEMobile', 'Edge', 'Midori', 'Vivaldi', 'OculusBrowser', 'SamsungBrowser', 'Valve Steam Tenfoot', 'Chrome', 'HeadlessChrome' ), $key, $browser) ) {
} elseif( $find(array( 'Applebot', 'IEMobile', 'Edge', 'Midori', 'Vivaldi', 'OculusBrowser', 'SamsungBrowser', 'Valve Steam Tenfoot', 'Chrome', 'HeadlessChrome' ), $key, $browser) ) {
$version = $result['version'][$key];
} elseif( $rv_result && $find('Trident') ) {
$browser = 'MSIE';
Expand Down
20 changes: 20 additions & 0 deletions tests/user_agents.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
{
"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit\/600.2.5\n(KHTML, like Gecko) Version\/8.0.2 Safari\/600.2.5 (Applebot\/0.1)": {
"platform": "Macintosh",
"browser": "Applebot",
"version": "0.1"
},
"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit\/605.1.15\n(KHTML, like Gecko) Version\/12.1.1 Safari\/605.1.15 (Applebot\/0.1)": {
"platform": "Macintosh",
"browser": "Applebot",
"version": "0.1"
},
"Mozilla\/5.0 (Macintosh; U; Intel Mac OS X; en; rv:1.8.1.11) Gecko\/20071128 Camino\/1.5.4": {
"platform": "Macintosh",
"browser": "Camino",
Expand Down Expand Up @@ -604,6 +614,16 @@
"browser": "UC Browser",
"version": "2.4.0.367"
},
"Mozilla\/5.0 (iPhone; CPU iPhone OS 8_1 like Mac OS X) AppleWebKit\/600.1.4\n(KHTML, like Gecko) Version\/8.0 Mobile\/12B410 Safari\/600.1.4 (Applebot\/0.1;\n+http:\/\/www.apple.com\/go\/applebot)": {
"platform": "iPhone",
"browser": "Applebot",
"version": "0.1"
},
"Mozilla\/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit\/605.1.15Z\n(KHTML, like Gecko) Version\/13.1 Mobile\/15E148 Safari\/604.1 (Applebot\/0.1)": {
"platform": "iPhone",
"browser": "Applebot",
"version": "0.1"
},
"Mozilla\/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en) AppleWebKit\/534.46.0 (KHTML, like Gecko) CriOS\/19.0.1084.60 Mobile\/9B206 Safari\/7534.48.3": {
"platform": "iPhone",
"browser": "Chrome",
Expand Down

0 comments on commit e159493

Please sign in to comment.