Skip to content

Commit

Permalink
Add support for Naver Whale
Browse files Browse the repository at this point in the history
  • Loading branch information
donatj committed Oct 30, 2024
1 parent e807895 commit 5e044f0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ Predefined helper constants from `donatj\UserAgent\Browsers`
| `Browsers::VALVE_STEAM_TENFOOT` | Valve Steam Tenfoot |
| `Browsers::VIVALDI` | Vivaldi |
| `Browsers::WGET` | Wget |
| `Browsers::WHALE` | Whale |
| `Browsers::WORDPRESS` | WordPress |
| `Browsers::YANDEX` | Yandex |
| `Browsers::YANDEXBOT` | YandexBot |
Expand Down
1 change: 1 addition & 0 deletions src/UserAgent/Browsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ interface Browsers {
const VALVE_STEAM_TENFOOT = 'Valve Steam Tenfoot';
const VIVALDI = 'Vivaldi';
const WGET = 'Wget';
const WHALE = 'Whale';
const WORDPRESS = 'WordPress';
const YANDEX = 'Yandex';
const YANDEXBOT = 'YandexBot';
Expand Down
4 changes: 2 additions & 2 deletions src/UserAgentParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function parse_user_agent( $u_agent = null ) {
preg_match_all(<<<'REGEX'
%(?P<browser>Camino|Kindle(\ Fire)?|Firefox|Iceweasel|IceCat|Safari|MSIE|Trident|AppleWebKit|
TizenBrowser|(?:Headless)?Chrome|YaBrowser|Vivaldi|IEMobile|Opera|OPR|Silk|Midori|(?-i:Edge)|EdgA?|CriOS|UCBrowser|Puffin|
OculusBrowser|SamsungBrowser|SailfishBrowser|XiaoMi/MiuiBrowser|YaApp_Android|
OculusBrowser|SamsungBrowser|SailfishBrowser|XiaoMi/MiuiBrowser|YaApp_Android|Whale|
Baiduspider|Applebot|Facebot|Googlebot|YandexBot|bingbot|Lynx|Version|Wget|curl|ChatGPT-User|GPTBot|OAI-SearchBot|
Valve\ Steam\ Tenfoot|Mastodon|
NintendoBrowser|PLAYSTATION\ (?:\d|Vita)+)
Expand Down Expand Up @@ -188,7 +188,7 @@ function parse_user_agent( $u_agent = null ) {
}
}
}
} elseif( $find([ 'Googlebot', 'Applebot', 'IEMobile', 'Edge', 'Midori', 'Vivaldi', 'OculusBrowser', 'SamsungBrowser', 'Valve Steam Tenfoot', 'Chrome', 'HeadlessChrome', 'SailfishBrowser' ], $key, $browser) ) {
} elseif( $find([ 'Googlebot', 'Applebot', 'IEMobile', 'Edge', 'Midori', 'Whale', '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
35 changes: 35 additions & 0 deletions tests/user_agents.dist.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,26 @@
"browser": "Wget",
"version": "1.12"
},
"Mozilla\/5.0 (X11; CrOS x86_64 2.22.17) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/108.0.0.0 Whale\/3.18.186.3 Safari\/537.36": {
"platform": "Chrome OS",
"browser": "Whale",
"version": "3.18.186.3"
},
"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/120.0.0.0 Whale\/3.24.223.21 Safari\/537.36": {
"platform": "Macintosh",
"browser": "Whale",
"version": "3.24.223.21"
},
"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/128.0.0.0 Whale\/3.28.266.11 Safari\/537.36": {
"platform": "Macintosh",
"browser": "Whale",
"version": "3.28.266.11"
},
"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/128.0.0.0 Whale\/3.28.266.14 Safari\/537.36": {
"platform": "Windows",
"browser": "Whale",
"version": "3.28.266.14"
},
"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit\/536.5 (KHTML, like Gecko) YaBrowser\/1.0.1084.5402 Chrome\/19.0.1084.5402 Safari\/536.5": {
"platform": "Macintosh",
"browser": "Yandex",
Expand Down Expand Up @@ -839,6 +859,16 @@
"browser": "UC Browser",
"version": "13.0.8.1291"
},
"Mozilla\/5.0 (Linux; Android 13; SM-F926N) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/102.0.5005.187 Whale\/2.7.8.2 Safari\/537.36": {
"platform": "Android",
"browser": "Whale",
"version": "2.7.8.2"
},
"Mozilla\/5.0 (Linux; Android 10; K) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/120.0.0.0 Whale\/3.5.4.2 Mobile Safari\/537.36": {
"platform": "Android",
"browser": "Whale",
"version": "3.5.4.2"
},
"Mozilla\/5.0 (Linux; arm_64; Android 12; SM-G965F) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/100.0.4896.127 YaBrowser\/21.3.4.59 Mobile Safari\/537.36": {
"platform": "Android",
"browser": "Yandex",
Expand Down Expand Up @@ -939,6 +969,11 @@
"browser": "UC Browser",
"version": "2.4.0.367"
},
"Mozilla\/5.0 (iPad; CPU OS 16_5_1 like Mac OS X) AppleWebKit\/605.1.15 (KHTML, like Gecko) Version\/16.0 Whale\/2.8.8.3883 Mobile\/15E148 Safari\/604.1": {
"platform": "iPad",
"browser": "Whale",
"version": "2.8.8.3883"
},
"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",
Expand Down

0 comments on commit 5e044f0

Please sign in to comment.