aboutsummaryrefslogtreecommitdiff
path: root/pkg/config/url.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/config/url.go')
-rw-r--r--pkg/config/url.go27
1 files changed, 19 insertions, 8 deletions
diff --git a/pkg/config/url.go b/pkg/config/url.go
index 7e91411..4b3abf7 100644
--- a/pkg/config/url.go
+++ b/pkg/config/url.go
@@ -65,18 +65,29 @@ func (u *Url) UnmarshalYAML(value *yaml.Node) (err error) {
}
func (u Url) String() string {
- scheme := u.Scheme + "://"
+ var sb strings.Builder
- var pwd string
- if u.Password != "" {
- pwd = ":******"
+ sb.WriteString(u.Scheme)
+ sb.WriteString("://")
+
+ if u.User != "" {
+ sb.WriteString(u.User)
+ if u.Password != "" {
+ sb.WriteString(":******")
+ }
+ sb.WriteRune('@')
}
- var delim string
- if pwd != "" || u.User != "" {
- delim = "@"
+
+ sb.WriteString(u.HostPort())
+
+ if u.Root != "" {
+ if u.Root[0] != '/' {
+ sb.WriteRune('/')
+ }
+ sb.WriteString(u.Root)
}
- return scheme + u.User + pwd + delim + u.HostPort() + u.Root
+ return sb.String()
}
func (u *Url) HostPort() string {