src/WingetCreateCore/Common/PackageParser.cs
/// <summary>
/// Performs a regex match to determine the installer architecture based on the url string.
/// </summary>
/// <param name="url">Installer url string.</param>
/// <returns>Installer architecture enum.</returns>
Performs a regex match to determine the installer architecture based on the url string.
Performs a regex match to determine the installer architecture based on the url string .
private static InstallerArchitecture? GetArchFromUrl(string url)
        {
            List<InstallerArchitecture> archMatches = new List<InstallerArchitecture>();
            if (Regex.Match(url, "arm64|aarch64", RegexOptions.IgnoreCase).Success)
            {
                archMatches.Add(InstallerArchitecture.Arm64);
            }
            else if (Regex.Match(url, @"\barm\b", RegexOptions.IgnoreCase).Success)
            {
                archMatches.Add(InstallerArchitecture.Arm);
            }
            if (Regex.Match(url, "x64|win64|_64|64-bit", RegexOptions.IgnoreCase).Success)
            {
                archMatches.Add(InstallerArchitecture.X64);
            }
            if (Regex.Match(url, "x86|win32|ia32|_86|32-bit", RegexOptions.IgnoreCase).Success)
            {
                archMatches.Add(InstallerArchitecture.X86);
            }
            return archMatches.Count == 1 ? archMatches.Single() : null;
        }
private static InstallerArchitecture ? GetArchFromUrl ( string url ) { List < InstallerArchitecture > archMatches = new List < InstallerArchitecture > ( ) ; if ( Regex . Match ( url , " " , RegexOptions . IgnoreCase ) . Success ) { archMatches . Add ( InstallerArchitecture . Arm64 ) ; } else if ( Regex . Match ( url , @"\barm\b" , RegexOptions . IgnoreCase ) . Success ) { archMatches . Add ( InstallerArchitecture . Arm ) ; } if ( Regex . Match ( url , " " , RegexOptions . IgnoreCase ) . Success ) { archMatches . Add ( InstallerArchitecture . X64 ) ; } if ( Regex . Match ( url , " " , RegexOptions . IgnoreCase ) . Success ) { archMatches . Add ( InstallerArchitecture . X86 ) ; } return archMatches . Count == 1 ? archMatches . Single ( ) : null ; }
Performs a regex match to determine the installer architecture based on the url string.
Performs a regex match to determine the installer architecture based on the url string .
// Arm must only be checked if arm64 check fails, otherwise it'll match for arm64 too
Installer architecture enum.
Installer architecture enum .
url
string
Installer url string.
Installer url string .