feat: ds
This commit is contained in:
@@ -25,6 +25,14 @@ final class UserAgentParser
|
||||
[$os, $osVersion] = self::parseOs($ua);
|
||||
[$browser, $browserVersion] = self::parseBrowser($ua);
|
||||
|
||||
// iOS 26+ Safari still reports "iPhone OS 18_7" for compatibility.
|
||||
// When Version/ is 26+ and the OS token is 18.7, use Version/ for both fields.
|
||||
$compatVersion = self::ios26CompatVersion($ua);
|
||||
if ($compatVersion !== null && self::isIos187CompatToken($os, $osVersion)) {
|
||||
$osVersion = $compatVersion;
|
||||
$browserVersion = $compatVersion;
|
||||
}
|
||||
|
||||
return [
|
||||
'os' => $os,
|
||||
'os_version' => $osVersion,
|
||||
@@ -33,6 +41,29 @@ final class UserAgentParser
|
||||
];
|
||||
}
|
||||
|
||||
private static function isIos187CompatToken(string $os, string $osVersion): bool
|
||||
{
|
||||
if (! in_array($os, ['iOS', 'iPadOS'], true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $osVersion === '18.7' || str_starts_with($osVersion, '18.7.');
|
||||
}
|
||||
|
||||
private static function ios26CompatVersion(string $ua): ?string
|
||||
{
|
||||
if (! preg_match('/Version\/(\d+(?:\.\d+){0,2})/i', $ua, $m)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$major = (int) explode('.', $m[1])[0];
|
||||
if ($major < 26) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $m[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0: string, 1: string}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user