Skip to content

Commit

Permalink
Fix rendering when folders start with another one's partial match
Browse files Browse the repository at this point in the history
This was causing buildTransitive/* to be grouped under build/*
  • Loading branch information
kzu committed Oct 25, 2020
1 parent 1b01911 commit c1d3ab0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/dotnet-nugetize/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,16 @@ int Execute()

static int Render(IList<XElement> files, int index, int level, string path)
{
var normalizedLevelPath = path == "" ? Path.DirectorySeparatorChar.ToString() : (Path.DirectorySeparatorChar + path + Path.DirectorySeparatorChar);
while (index < files.Count)
{
var element = files[index];
var file = element.Element("PackagePath").Value;
var dir = Path.GetDirectoryName(file);
var paths = dir.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
var normalizeCurrentPath = Path.DirectorySeparatorChar + string.Join(Path.DirectorySeparatorChar, paths) + Path.DirectorySeparatorChar;

if (!string.Join(Path.DirectorySeparatorChar, paths).StartsWith(path) ||
paths.Length < level)
if (!normalizeCurrentPath.StartsWith(normalizedLevelPath) || paths.Length < level)
return index;

if (paths.Length > level)
Expand Down

0 comments on commit c1d3ab0

Please sign in to comment.