diff --git a/src/code/LocalServerApiCalls.cs b/src/code/LocalServerApiCalls.cs index 1dca86200..551a3fb3d 100644 --- a/src/code/LocalServerApiCalls.cs +++ b/src/code/LocalServerApiCalls.cs @@ -260,7 +260,7 @@ private FindResults FindNameHelper(string packageName, string[] tags, bool inclu string actualPkgName = packageName; // this regex pattern matches packageName followed by a version (4 digit or 3 with prerelease word) - string regexPattern = $"{packageName}" + @".\d+\.\d+\.\d+(?:-\w+|.\d)*.nupkg"; + string regexPattern = $"{packageName}" + @".\d+\.\d+\.\d+(?:[a-zA-Z0-9-.]+|.\d)?.nupkg"; Regex rx = new Regex(regexPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase); _cmdletPassedIn.WriteDebug($"package file name pattern to be searched for is: {regexPattern}"); diff --git a/test/FindPSResourceTests/FindPSResourceLocal.Tests.ps1 b/test/FindPSResourceTests/FindPSResourceLocal.Tests.ps1 index ec0a9d873..1377cac2f 100644 --- a/test/FindPSResourceTests/FindPSResourceLocal.Tests.ps1 +++ b/test/FindPSResourceTests/FindPSResourceLocal.Tests.ps1 @@ -19,8 +19,10 @@ Describe 'Test Find-PSResource for local repositories' -tags 'CI' { $commandName = "cmd1" $dscResourceName = "dsc1" $prereleaseLabel = "" + $localNupkgRepo = "localNupkgRepo" Get-NewPSResourceRepositoryFile Register-LocalRepos + Register-LocalTestNupkgsRepo $localRepoUriAddress = Join-Path -Path $TestDrive -ChildPath "testdir" $tagsEscaped = @("'Test'", "'Tag2'", "'PSCommand_$cmdName'", "'PSDscResource_$dscName'") @@ -319,4 +321,14 @@ Describe 'Test Find-PSResource for local repositories' -tags 'CI' { $err.Count | Should -Not -Be 0 $err[0].FullyQualifiedErrorId | Should -BeExactly "FindTagsPackageNotFound,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource" } + + It "find package where prerelease label includes digits and period (i.e prerelease label is not just words)" { + $nupkgName = "WebView2.Avalonia" + $nupkgVersion = "1.0.1518.46" + $prereleaseLabel = "preview.230207.17" + $res = Find-PSResource -Name $nupkgName -Prerelease -Repository $localNupkgRepo + $res.Name | Should -Be $nupkgName + $res.Version | Should -Be $nupkgVersion + $res.Prerelease | Should -Be $prereleaseLabel + } } diff --git a/test/testFiles/testNupkgs/webview2.avalonia.1.0.1518.46-preview.230207.17.nupkg b/test/testFiles/testNupkgs/webview2.avalonia.1.0.1518.46-preview.230207.17.nupkg new file mode 100644 index 000000000..e47c80773 Binary files /dev/null and b/test/testFiles/testNupkgs/webview2.avalonia.1.0.1518.46-preview.230207.17.nupkg differ