aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/aws/aws-sdk-go/internal/sdkuri/path.go
blob: 38ea61afeaa63568f01d3ecca6c7a95754f2dd86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package sdkuri

import (
	"path"
	"strings"
)

// PathJoin will join the elements of the path delimited by the "/"
// character. Similar to path.Join with the exception the trailing "/"
// character is preserved if present.
func PathJoin(elems ...string) string {
	if len(elems) == 0 {
		return ""
	}

	hasTrailing := strings.HasSuffix(elems[len(elems)-1], "/")
	str := path.Join(elems...)
	if hasTrailing && str != "/" {
		str += "/"
	}

	return str
}