diff --git a/app/Platform/Services/UserAgentService.php b/app/Platform/Services/UserAgentService.php index f046447e4d..6117344089 100644 --- a/app/Platform/Services/UserAgentService.php +++ b/app/Platform/Services/UserAgentService.php @@ -141,6 +141,9 @@ private function parseUserAgent(string $userAgent): array // promote libretro core information $index = strpos($client, '_libretro'); + if ($index === false) { + $index = strpos($client, '.libretro'); + } if ($index !== false) { $data['clientVariation'] = substr($client, 0, $index); } diff --git a/tests/Feature/Platform/Services/UserAgentServiceTest.php b/tests/Feature/Platform/Services/UserAgentServiceTest.php index 57de6894c3..0b7717d41c 100644 --- a/tests/Feature/Platform/Services/UserAgentServiceTest.php +++ b/tests/Feature/Platform/Services/UserAgentServiceTest.php @@ -109,6 +109,21 @@ public function testRetroArchUserAgentWithCore(): void ], $this->parseUserAgent($userAgent)); } + public function testRetroArchUserAgentWithCoreIOS(): void + { + $userAgent = 'RetroArch/1.20.0 (iOS 17.5) mgba.libretro/0.11-dev_747362c'; + + $this->assertEquals([ + 'client' => 'RetroArch', + 'clientVersion' => '1.20.0', + 'os' => 'iOS 17.5', + 'clientVariation' => 'mgba', + 'extra' => [ + 'mgba.libretro' => '0.11-dev_747362c', + ], + ], $this->parseUserAgent($userAgent)); + } + public function testRetroArchUserAgentWithCoreVersionContainingParentheses(): void { $userAgent = 'RetroArch/1.19.1 (Windows 8 x64 Build 9200 6.2) parallel_n64_next_libretro/2.21.0_(Parallel_Launcher_Edition)'; @@ -537,4 +552,19 @@ public function testXbsx2UserAgent(): void 'os' => 'Microsoft Windows 10+, Xbox One X', ], $this->parseUserAgent($userAgent)); } + + public function testLunaProject64UserAgent(): void + { + $userAgent = 'LunaProject64/3.0.1.5865-5ba8d97c-Dirty (WindowsNT 10.0) Integration/1.3.0'; + + $this->assertEquals([ + 'client' => 'LunaProject64', + 'clientVersion' => '3.0.1.5865-5ba8d97c-Dirty', + 'os' => 'WindowsNT 10.0', + 'integrationVersion' => '1.3.0', + ], $this->parseUserAgent($userAgent)); + + $this->assertEquals(1, UserAgentService::versionCompare('3.0.1.5865-5ba8d97c-Dirty', '3.0.1.5864')); + $this->assertEquals(-1, UserAgentService::versionCompare('3.0.1.5865-5ba8d97c-Dirty', '3.0.1.5866')); + } }