Skip to content

Commit

Permalink
Merge pull request #98 from donatj/mastodon
Browse files Browse the repository at this point in the history
Roughs in Mastodon support + Improve Googlebot Support
  • Loading branch information
donatj authored Aug 28, 2024
2 parents e9db3b6 + 385d3f5 commit cf48756
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/UserAgent/Browsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface Browsers {
const IMESSAGEBOT = 'iMessageBot';
const KINDLE = 'Kindle';
const LYNX = 'Lynx';
const MASTODON = 'Mastodon';
const MIDORI = 'Midori';
const MIUIBROWSER = 'MiuiBrowser';
const MSIE = 'MSIE';
Expand Down
4 changes: 2 additions & 2 deletions src/UserAgentParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function parse_user_agent( $u_agent = null ) {
TizenBrowser|(?:Headless)?Chrome|YaBrowser|Vivaldi|IEMobile|Opera|OPR|Silk|Midori|(?-i:Edge)|EdgA?|CriOS|UCBrowser|Puffin|
OculusBrowser|SamsungBrowser|SailfishBrowser|XiaoMi/MiuiBrowser|YaApp_Android|
Baiduspider|Applebot|Facebot|Googlebot|YandexBot|bingbot|Lynx|Version|Wget|curl|ChatGPT-User|GPTBot|OAI-SearchBot|
Valve\ Steam\ Tenfoot|
Valve\ Steam\ Tenfoot|Mastodon|
NintendoBrowser|PLAYSTATION\ (?:\d|Vita)+)
\)?;?
(?:[:/ ](?P<version>[0-9A-Z.]+)|/[A-Z]*)
Expand Down Expand Up @@ -188,7 +188,7 @@ function parse_user_agent( $u_agent = null ) {
}
}
}
} elseif( $find([ 'Applebot', 'IEMobile', 'Edge', 'Midori', 'Vivaldi', 'OculusBrowser', 'SamsungBrowser', 'Valve Steam Tenfoot', 'Chrome', 'HeadlessChrome', 'SailfishBrowser' ], $key, $browser) ) {
} elseif( $find([ 'Googlebot', 'Applebot', 'IEMobile', 'Edge', 'Midori', 'Vivaldi', 'OculusBrowser', 'SamsungBrowser', 'Valve Steam Tenfoot', 'Chrome', 'HeadlessChrome', 'SailfishBrowser' ], $key, $browser) ) {
$version = $result[BROWSER_VERSION][$key];
} elseif( $rv_result && $find('Trident') ) {
$browser = 'MSIE';
Expand Down
20 changes: 20 additions & 0 deletions tests/user_agents.dist.json
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,11 @@
"browser": "Firefox",
"version": "84.0"
},
"Mozilla\/5.0 (Linux; Android 6.0.1; Nexus 5X Build\/MMB29P) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/90.0.4430.97 Mobile Safari\/537.36 (compatible; Googlebot\/2.1; +http:\/\/www.google.com\/bot.html)": {
"platform": "Android",
"browser": "Googlebot",
"version": "2.1"
},
"Mozilla\/5.0 (Linux; U; Android 8.1.0; en-gb; Redmi Note 5 Build\/OPM1.171019.011)\nAppleWebKit\/537.36 (KHTML, like Gecko) Version\/4.0 Chrome\/61.0.3163.128 Mobile\nSafari\/537.36 XiaoMi\/MiuiBrowser\/10.1.2": {
"platform": "Android",
"browser": "MiuiBrowser",
Expand Down Expand Up @@ -1429,6 +1434,11 @@
"browser": "Googlebot",
"version": "1.3"
},
"Chrome\/90.0.4430.97 Mobile Safari\/537.36 (compatible; Googlebot\/2.1; +http:\/\/www.google.com\/bot.html)": {
"platform": null,
"browser": "Googlebot",
"version": "2.1"
},
"Mozilla\/5.0 (compatible; Googlebot\/2.1; +http:\/\/www.google.com\/bot.html)": {
"platform": null,
"browser": "Googlebot",
Expand All @@ -1454,6 +1464,16 @@
"browser": "Lynx",
"version": "2.8.6rel.4"
},
"http.rb\/5.1.1 (Mastodon\/4.2.5; +https:\/\/m.t-8.me\/)": {
"platform": null,
"browser": "Mastodon",
"version": "4.2.5"
},
"http.rb\/5.2.0 (Mastodon\/4.3.0-alpha.3; +https:\/\/mstdn.social\/)": {
"platform": null,
"browser": "Mastodon",
"version": "4.3.0"
},
"msnbot-media\/1.1 (+http:\/\/search.msn.com\/msnbot.htm)": {
"platform": null,
"browser": "msnbot-media",
Expand Down

0 comments on commit cf48756

Please sign in to comment.