@@ -427,7 +427,7 @@ func (a *App) upload() *cobra.Command { //nolint:funlen
427427 source := filepath .Clean (args [0 ])
428428 target := a .Path (args [1 ])
429429
430- if strings .HasSuffix (args [1 ], "/" ) && ! strings . HasSuffix (args [0 ], "/" ) && ! strings . HasSuffix ( args [ 0 ], string ( os . PathSeparator ) ) {
430+ if strings .HasSuffix (args [1 ], "/" ) && ! localPathEndsWithSeparator (args [0 ]) {
431431 target = a .Path (args [1 ] + filepath .Base (source ))
432432 }
433433
@@ -506,7 +506,7 @@ func (a *App) download() *cobra.Command { //nolint:funlen
506506 source := a .Path (args [0 ])
507507 target := filepath .Clean (args [1 ])
508508
509- if ( strings . HasSuffix ( args [1 ], "/" ) || strings . HasSuffix ( args [ 1 ], string ( os . PathSeparator )) ) && ! strings .HasSuffix (args [0 ], "/" ) {
509+ if localPathEndsWithSeparator ( args [1 ]) && ! strings .HasSuffix (args [0 ], "/" ) {
510510 target = filepath .Join (target , Name (source ))
511511 }
512512
@@ -523,7 +523,7 @@ func (a *App) download() *cobra.Command { //nolint:funlen
523523 return a .Download (cmd .Context (), target , source , opts )
524524 }
525525
526- if ! strings . HasSuffix (args [1 ], "/" ) && ! strings . HasSuffix ( args [ 1 ], string ( os . PathSeparator ) ) {
526+ if ! localPathEndsWithSeparator (args [1 ]) {
527527 return ErrAmbiguousTarget
528528 }
529529
@@ -539,6 +539,10 @@ func (a *App) download() *cobra.Command { //nolint:funlen
539539 return cmd
540540}
541541
542+ func localPathEndsWithSeparator (path string ) bool {
543+ return strings .HasSuffix (path , "/" ) || strings .HasSuffix (path , string (os .PathSeparator ))
544+ }
545+
542546func (a * App ) cat () * cobra.Command {
543547 var maxThreads int
544548
0 commit comments