diff --git a/dotnet/src/dotnetframework/GxClasses/Printer/GxPrinter.cs b/dotnet/src/dotnetframework/GxClasses/Printer/GxPrinter.cs index 70b560aed..f3b8dd6cd 100644 --- a/dotnet/src/dotnetframework/GxClasses/Printer/GxPrinter.cs +++ b/dotnet/src/dotnetframework/GxClasses/Printer/GxPrinter.cs @@ -2139,11 +2139,11 @@ public class ReportUtils { static public string AddPath(string name, string path) { - if( name.IndexOf(":") != -1 || + if (Path.IsPathRooted(name) || name.IndexOf(":") != -1 || (name.Length >=2 && (name.Substring( 0,2) == "//" || name.Substring( 0,2) == @"\\")) || (name.StartsWith("http:" ) || name.StartsWith("https:" ))) return name; - return path + name; + return Path.Combine(path, name); } } diff --git a/dotnet/test/DotNetUnitTest/FileIO/FileIOTests.cs b/dotnet/test/DotNetUnitTest/FileIO/FileIOTests.cs index a8cab65c2..28decb1d7 100644 --- a/dotnet/test/DotNetUnitTest/FileIO/FileIOTests.cs +++ b/dotnet/test/DotNetUnitTest/FileIO/FileIOTests.cs @@ -1,6 +1,7 @@ using System; using System.IO; using GeneXus.Configuration; +using GeneXus.Printer; using GeneXus.Utils; using Xunit; @@ -89,5 +90,32 @@ public void PathUtilGetValidFileName() fileName = PathUtil.GetValidFileName(path, "_"); Assert.StartsWith("Screen Shot 2016-02-15 at 11.41.55 AM", fileName, StringComparison.OrdinalIgnoreCase); } + + [Fact] + public void ReportUtilAddPathLinux() + { + string name = "/mnt/c/Models/DockerReport/NETModel/Web/PublicTempStorage/clientreportebee6af4-7554-4283-b246-e1600e49b103.pdf"; + string path = "/mnt/c/Models/DockerReport/NETModel/Web/"; + string fullPath = ReportUtils.AddPath(name, path); + Assert.Equal(name, fullPath); + } + + [Fact] + public void ReportUtilAddPathWindows() + { + string name = "PublicTempStorage/clientreportebee6af4-7554-4283-b246-e1600e49b103.pdf"; + string path = "C:/Models/Report/NETModel/Web/"; + string fullPath = ReportUtils.AddPath(name, path); + + Assert.Equal(Path.Combine(path, name), fullPath); + } + [Fact] + public void ReportUtilAddPathHttp() + { + string name = "http://localhost:5000/WebApp/PublicTempStorage/clientreportebee6af4-7554-4283-b246-e1600e49b103.pdf"; + string path = "C:/Models/Report/NETModel/Web/"; + string fullPath = ReportUtils.AddPath(name, path); + Assert.Equal(name, fullPath); + } } }