From e691cd2a81b0cc577942ebd5a4d5007a48170357 Mon Sep 17 00:00:00 2001
From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com>
Date: Thu, 29 Jun 2023 09:18:50 +0200
Subject: [PATCH] fix: Copy files to container without removing first character
 from filename

---
 src/Testcontainers/Containers/TarOutputMemoryStream.cs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Testcontainers/Containers/TarOutputMemoryStream.cs b/src/Testcontainers/Containers/TarOutputMemoryStream.cs
index 61032c88a..8b809ba90 100644
--- a/src/Testcontainers/Containers/TarOutputMemoryStream.cs
+++ b/src/Testcontainers/Containers/TarOutputMemoryStream.cs
@@ -108,7 +108,7 @@ public async Task AddAsync(DirectoryInfo directory, FileInfo file, UnixFileModes
     {
       using (var stream = new FileStream(file.FullName, FileMode.Open, FileAccess.Read))
       {
-        var targetFilePath = Unix.Instance.NormalizePath(Path.Combine(_targetDirectoryPath, file.FullName.Substring(directory.FullName.Length + 1)));
+        var targetFilePath = Unix.Instance.NormalizePath(Path.Combine(_targetDirectoryPath, file.FullName.Substring(directory.FullName.TrimEnd(Path.DirectorySeparatorChar).Length + 1)));
 
         var tarEntry = new TarEntry(new TarHeader());
         tarEntry.TarHeader.Name = targetFilePath;