@@ -10,6 +10,7 @@ import (
1010 "net/http"
1111 "net/url"
1212 "os"
13+ "path"
1314 "path/filepath"
1415 "strings"
1516 "time"
@@ -342,9 +343,12 @@ func resolveDestPath(ctx context.Context, baseURL, apiKey, instanceID, srcPath,
342343 }
343344
344345 // Check if dstPath ends with /. (copy contents only)
345- copyContentsOnly := strings .HasSuffix (srcPath , string (filepath .Separator )+ "." )
346+ // Handle both OS-specific separator and forward slash for cross-platform compatibility
347+ copyContentsOnly := strings .HasSuffix (srcPath , string (filepath .Separator )+ "." ) ||
348+ strings .HasSuffix (srcPath , "/." )
346349 if copyContentsOnly {
347350 srcPath = strings .TrimSuffix (srcPath , string (filepath .Separator )+ "." )
351+ srcPath = strings .TrimSuffix (srcPath , "/." )
348352 }
349353
350354 // Check if destination ends with /
@@ -380,7 +384,8 @@ func resolveDestPath(ctx context.Context, baseURL, apiKey, instanceID, srcPath,
380384 }
381385 if dstStat .IsDir {
382386 // Copy into directory using basename
383- return filepath .Join (dstPath , filepath .Base (srcPath )), nil
387+ // Use path.Join for guest paths (always forward slashes)
388+ return path .Join (dstPath , filepath .Base (srcPath )), nil
384389 }
385390 // Overwrite file
386391 return dstPath , nil
@@ -403,7 +408,8 @@ func resolveDestPath(ctx context.Context, baseURL, apiKey, instanceID, srcPath,
403408 }
404409
405410 // Copy SRC dir into DEST (create subdir)
406- return filepath .Join (dstPath , filepath .Base (srcPath )), nil
411+ // Use path.Join for guest paths (always forward slashes)
412+ return path .Join (dstPath , filepath .Base (srcPath )), nil
407413}
408414
409415// buildCpWsURL builds the WebSocket URL for the cp endpoint
@@ -549,7 +555,8 @@ func copyDirContentsToInstance(ctx context.Context, baseURL, apiKey, instanceID,
549555
550556 for _ , entry := range entries {
551557 srcEntryPath := filepath .Join (srcPath , entry .Name ())
552- dstEntryPath := filepath .Join (dstPath , entry .Name ())
558+ // Use path.Join for guest paths (always forward slashes)
559+ dstEntryPath := path .Join (dstPath , entry .Name ())
553560
554561 info , err := entry .Info ()
555562 if err != nil {
0 commit comments