From 3d34a45e857f781b89aeb0a0d7f8f0b634fe28cf Mon Sep 17 00:00:00 2001 From: Xavier Decoster Date: Thu, 11 May 2017 16:53:29 +0200 Subject: [PATCH] Fix functional test failure SearchMicrosoftDotNetCuratedFeed #3941 (#3942) --- .../OData/Serializers/V2FeedPackageAnnotationStrategy.cs | 6 +++++- .../Serializers/V2FeedPackageAnnotationStrategyFacts.cs | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/NuGetGallery/OData/Serializers/V2FeedPackageAnnotationStrategy.cs b/src/NuGetGallery/OData/Serializers/V2FeedPackageAnnotationStrategy.cs index 60b5cae411..8ddf9562e0 100644 --- a/src/NuGetGallery/OData/Serializers/V2FeedPackageAnnotationStrategy.cs +++ b/src/NuGetGallery/OData/Serializers/V2FeedPackageAnnotationStrategy.cs @@ -85,7 +85,11 @@ private static void NormalizeNavigationLinks(ODataEntry entry, HttpRequestMessag private static Uri BuildIdLink(string id, string version, HttpRequestMessage request) { var packageIdentityQuery = $"(Id='{id}',Version='{version}')"; - var localPath = request.RequestUri.LocalPath.Replace(packageIdentityQuery, string.Empty); + var localPath = request.RequestUri.LocalPath + // Remove closing brackets from Packages collection + .Replace("/Packages()", "/Packages") + // Remove package identity query + .Replace(packageIdentityQuery, string.Empty); return new Uri($"{request.RequestUri.Scheme}://{request.RequestUri.Host}{localPath}{packageIdentityQuery}"); } diff --git a/tests/NuGetGallery.Facts/OData/Serializers/V2FeedPackageAnnotationStrategyFacts.cs b/tests/NuGetGallery.Facts/OData/Serializers/V2FeedPackageAnnotationStrategyFacts.cs index 843eade501..2084b10636 100644 --- a/tests/NuGetGallery.Facts/OData/Serializers/V2FeedPackageAnnotationStrategyFacts.cs +++ b/tests/NuGetGallery.Facts/OData/Serializers/V2FeedPackageAnnotationStrategyFacts.cs @@ -83,6 +83,7 @@ public void SetsAtomEntryMetadataAnnotation() [Theory] [InlineData("https://localhost/api/v2/Packages")] + [InlineData("https://localhost/api/v2/Packages()")] [InlineData("https://localhost/api/v2/Packages(Id='SomePackageId',Version='1.0.0')")] public void NormalizesNavigationLinksWhenSet(string requestUri) {