diff --git a/src/NuGetGallery.Core/NuGetVersionExtensions.cs b/src/NuGetGallery.Core/NuGetVersionExtensions.cs index 8877b55a2c..af986e3c87 100644 --- a/src/NuGetGallery.Core/NuGetVersionExtensions.cs +++ b/src/NuGetGallery.Core/NuGetVersionExtensions.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Text.RegularExpressions; +using NuGet.Services.Entities; using NuGet.Versioning; namespace NuGetGallery @@ -31,6 +32,16 @@ public static string ToFullString(string version) return version; } } + + public static string GetNormalizedPackageVersion(Package package) + { + if (package == null) + { + return string.Empty; + } + + return string.IsNullOrEmpty(package.NormalizedVersion) ? Normalize(package.Version) : package.NormalizedVersion; + } } public static class NuGetVersionExtensions diff --git a/src/NuGetGallery.Core/Services/FIleNameHelper.cs b/src/NuGetGallery.Core/Services/FIleNameHelper.cs index 6b614d5cc7..be18f32092 100644 --- a/src/NuGetGallery.Core/Services/FIleNameHelper.cs +++ b/src/NuGetGallery.Core/Services/FIleNameHelper.cs @@ -29,9 +29,8 @@ public static string BuildFileName(Package package, string format, string exten return BuildFileName( package.PackageRegistration.Id, - string.IsNullOrEmpty(package.NormalizedVersion) ? - NuGetVersionFormatter.Normalize(package.Version) : - package.NormalizedVersion, format, extension); + NuGetVersionFormatter.GetNormalizedPackageVersion(package), + format, extension); } public static string BuildFileName(string id, string version, string pathTemplate, string extension) diff --git a/src/NuGetGallery.Services/SupportRequest/SupportRequestService.cs b/src/NuGetGallery.Services/SupportRequest/SupportRequestService.cs index 3fcb2662ec..591c8fe695 100644 --- a/src/NuGetGallery.Services/SupportRequest/SupportRequestService.cs +++ b/src/NuGetGallery.Services/SupportRequest/SupportRequestService.cs @@ -201,7 +201,7 @@ public async Task AddNewSupportRequestAsync( newIssue.CreatedBy = loggedInUser; newIssue.OwnerEmail = requestorEmailAddress; newIssue.PackageId = package?.PackageRegistration.Id; - newIssue.PackageVersion = package?.Version; + newIssue.PackageVersion = NuGetVersionFormatter.GetNormalizedPackageVersion(package); newIssue.Reason = reason; newIssue.SiteRoot = _siteRoot; newIssue.UserKey = user?.Key;