Skip to content

Commit

Permalink
detect alternate core label (#3128)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras authored Jan 26, 2025
1 parent 9477c65 commit 853ea5a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/Platform/Services/UserAgentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
30 changes: 30 additions & 0 deletions tests/Feature/Platform/Services/UserAgentServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)';
Expand Down Expand Up @@ -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'));
}
}

0 comments on commit 853ea5a

Please sign in to comment.