From c1d3ab075807ddcf1e38e9fdf525da1f857d20d7 Mon Sep 17 00:00:00 2001 From: Daniel Cazzulino Date: Sun, 25 Oct 2020 01:04:58 -0300 Subject: [PATCH] Fix rendering when folders start with another one's partial match This was causing buildTransitive/* to be grouped under build/* --- src/dotnet-nugetize/Program.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dotnet-nugetize/Program.cs b/src/dotnet-nugetize/Program.cs index dc0a7a67..4bfa4610 100644 --- a/src/dotnet-nugetize/Program.cs +++ b/src/dotnet-nugetize/Program.cs @@ -272,15 +272,16 @@ int Execute() static int Render(IList 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)