Skip to content

Commit

Permalink
Fix incorrect regex for catching physical devices
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Romanov committed May 19, 2023
1 parent 40886bd commit fc68cb6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/DotNet.Meteor.Shared/Apple/SystemProfiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static class SystemProfiler {
public static List<DeviceData> PhysicalDevices() {
var profiler = PathUtils.SystemProfilerTool();
var devices = new List<DeviceData>();
var regex = new Regex(@"(iPhone:)[^,]*?Version:\s+(?<ver>\d+.\d+)[^,]*?Serial\sNumber:\s+(?<id>\S+)");
var regex = new Regex(@"(?<dev>iPhone|iPad):[^,]*?Version:\s+(?<ver>\d+.\d+)[^,]*?Serial\sNumber:\s+(?<id>\S+)");

ProcessResult result = new ProcessRunner(profiler, new ProcessArgumentBuilder()
.Append("SPUSBDataType"))
Expand All @@ -22,6 +22,7 @@ public static List<DeviceData> PhysicalDevices() {

foreach (Match match in regex.Matches(output)) {
var version = match.Groups["ver"].Value;
var device = match.Groups["dev"].Value;
var serial = match.Groups["id"].Value;
//For modern iOS devices, the serial number is 24 characters long
if (serial.Length == 24)
Expand All @@ -32,7 +33,7 @@ public static List<DeviceData> PhysicalDevices() {
IsRunning = true,
IsMobile = true,
RuntimeId = Runtimes.iOSArm64,
Name = $"iPhone {version}",
Name = $"{device} {version}",
Detail = Details.iOSDevice,
Platform = Platforms.iOS,
Serial = serial
Expand Down

0 comments on commit fc68cb6

Please sign in to comment.