diff options
Diffstat (limited to 'vendor/github.com/aws/aws-sdk-go/internal/sdkuri/path.go')
-rw-r--r-- | vendor/github.com/aws/aws-sdk-go/internal/sdkuri/path.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/vendor/github.com/aws/aws-sdk-go/internal/sdkuri/path.go b/vendor/github.com/aws/aws-sdk-go/internal/sdkuri/path.go new file mode 100644 index 0000000..38ea61a --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/internal/sdkuri/path.go | |||
@@ -0,0 +1,23 @@ | |||
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 | } | ||