From b78af9477186032e675b990df629dbc2f15d0a13 Mon Sep 17 00:00:00 2001 From: Mark Kraus Date: Fri, 27 Oct 2017 08:05:14 -0500 Subject: [PATCH 1/2] Use Regex to Capture Windows Version --- .../commands/utility/WebCmdlet/PSUserAgent.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/PSUserAgent.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/PSUserAgent.cs index 3b2b5792390..7fd144c3e34 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/PSUserAgent.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/PSUserAgent.cs @@ -6,6 +6,7 @@ using System.Management.Automation; using System.Runtime.InteropServices; using System.Globalization; +using System.Text.RegularExpressions; namespace Microsoft.PowerShell.Commands { @@ -131,7 +132,8 @@ internal static string PlatformName // only generate the windows user agent once if(s_windowsUserAgent == null){ // find the version in the windows operating system description - string versionText = OS.Substring(OS.LastIndexOf(" ") +1); + Regex pattern = new Regex(@"\d+(\.\d+)+"); + string versionText = pattern.Match(OS).Value; Version windowsPlatformversion = new Version(versionText); s_windowsUserAgent = $"Windows NT {windowsPlatformversion.Major}.{windowsPlatformversion.Minor}"; } From b642bf1892eb0de690c010717823fb8b02e1b174 Mon Sep 17 00:00:00 2001 From: Mark Kraus Date: Fri, 27 Oct 2017 08:42:44 -0500 Subject: [PATCH 2/2] [Feature] Run feature tests