File: path.go

package info (click to toggle)
golang-github-aws-aws-sdk-go 1.49.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 312,636 kB
  • sloc: makefile: 120
file content (23 lines) | stat: -rw-r--r-- 453 bytes parent folder | download | duplicates (6)
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
}