From 2a0c204eec3bc7ab9089e0a361cbe3e8fb4c8e91 Mon Sep 17 00:00:00 2001 From: Muhammad Danish <88161975+mdanish-kh@users.noreply.github.com> Date: Thu, 22 Aug 2024 00:12:41 +0500 Subject: [PATCH] Update regex for finding architecture from URL --- src/WingetCreateCore/Common/PackageParser.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/WingetCreateCore/Common/PackageParser.cs b/src/WingetCreateCore/Common/PackageParser.cs index e0ab8823..4220d314 100644 --- a/src/WingetCreateCore/Common/PackageParser.cs +++ b/src/WingetCreateCore/Common/PackageParser.cs @@ -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; }