Skip to content

Commit

Permalink
Stop using Title element as a fallback for PackageInfo.Id
Browse files Browse the repository at this point in the history
  • Loading branch information
emgarten committed Oct 13, 2015
1 parent cb116d3 commit 1b0fbbc
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace NuGet.Protocol.Core.v3.RemoteRepositories
public class RemoteV2FindPackageByIdResource : FindPackageByIdResource
{
private static readonly XName _xnameEntry = XName.Get("entry", "http://www.w3.org/2005/Atom");
private static readonly XName _xnameTitle = XName.Get("title", "http://www.w3.org/2005/Atom");
private static readonly XName _xnameContent = XName.Get("content", "http://www.w3.org/2005/Atom");
private static readonly XName _xnameLink = XName.Get("link", "http://www.w3.org/2005/Atom");
private static readonly XName _xnameProperties = XName.Get("properties", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
Expand Down Expand Up @@ -212,7 +211,6 @@ private static PackageInfo BuildModel(string id, XElement element)
{
var properties = element.Element(_xnameProperties);
var idElement = properties.Element(_xnameId);
var titleElement = element.Element(_xnameTitle);

var publishElement = properties.Element(_xnamePublish);
if (publishElement != null)
Expand All @@ -226,14 +224,12 @@ private static PackageInfo BuildModel(string id, XElement element)
}

return new PackageInfo
{
// If 'Id' element exist, use its value as accurate package Id
// Otherwise, use the value of 'title' if it exist
// Use the given Id as final fallback if all elements above don't exist
Id = idElement?.Value ?? titleElement?.Value ?? id,
Version = NuGetVersion.Parse(properties.Element(_xnameVersion).Value),
ContentUri = element.Element(_xnameContent).Attribute("src").Value,
};
{
// Use the given Id as final fallback if all elements above don't exist
Id = idElement?.Value ?? id,
Version = NuGetVersion.Parse(properties.Element(_xnameVersion).Value),
ContentUri = element.Element(_xnameContent).Attribute("src").Value,
};
}

private async Task<Stream> OpenNupkgStreamAsync(PackageInfo package, CancellationToken cancellationToken)
Expand Down

0 comments on commit 1b0fbbc

Please sign in to comment.