github.com/aavshr/aws-sdk-go@v1.41.3/internal/sdkuri/path.go (about)

     1  package sdkuri
     2  
     3  import (
     4  	"path"
     5  	"strings"
     6  )
     7  
     8  // PathJoin will join the elements of the path delimited by the "/"
     9  // character. Similar to path.Join with the exception the trailing "/"
    10  // character is preserved if present.
    11  func PathJoin(elems ...string) string {
    12  	if len(elems) == 0 {
    13  		return ""
    14  	}
    15  
    16  	hasTrailing := strings.HasSuffix(elems[len(elems)-1], "/")
    17  	str := path.Join(elems...)
    18  	if hasTrailing && str != "/" {
    19  		str += "/"
    20  	}
    21  
    22  	return str
    23  }