Skip to content

Commit

Permalink
Update regex for finding architecture from URL (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdanish-kh authored Aug 23, 2024
1 parent 2151b95 commit 4a7e642
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/WingetCreateCore/Common/PackageParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -653,16 +653,22 @@ private static bool ParsePackageAndGenerateInstallerNodes(InstallerMetadata inst
archMatches.Add(Architecture.Arm);
}

if (Regex.Match(url, "x64|winx?64|_64|64-?bit|ia64|amd64|x86(-|_)64", RegexOptions.IgnoreCase).Success)
if (Regex.Match(url, "x64|winx?64|_64|64-?bit|ia64|amd64", RegexOptions.IgnoreCase).Success)
{
archMatches.Add(Architecture.X64);
}

if (Regex.Match(url, @"x86|win32|winx86|_86|32-?bit|ia32|i[3456]86|\b[3456]86\b", RegexOptions.IgnoreCase).Success)
// x86 must only be checked if the URL doesn't match an x86_64 like pattern, which is for x64
if (Regex.Match(url, "x86(-|_)x?64", RegexOptions.IgnoreCase).Success)
{
archMatches.Add(Architecture.X64);
}
else if (Regex.Match(url, @"x86|win32|winx86|_86|32-?bit|ia32|i[3456]86|\b[3456]86\b", RegexOptions.IgnoreCase).Success)
{
archMatches.Add(Architecture.X86);
}

archMatches = archMatches.Distinct().ToList();
return archMatches.Count == 1 ? archMatches.Single() : null;
}

Expand Down

0 comments on commit 4a7e642

Please sign in to comment.