Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update regex for finding architecture from URL #551

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading