From 44ff3d08a0e1f3b49e07795a9fdb0ad3af4c7540 Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Sun, 17 Oct 2021 16:52:16 +0200 Subject: URL: Do not print '@' when no user is given --- pkg/config/url.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'pkg/config/url.go') diff --git a/pkg/config/url.go b/pkg/config/url.go index 9621672..39cce16 100644 --- a/pkg/config/url.go +++ b/pkg/config/url.go @@ -64,12 +64,18 @@ func (u *Url) UnmarshalYAML(value *yaml.Node) (err error) { } func (u *Url) String() string { + scheme := u.Scheme + "://" + var pwd string if u.Password != "" { pwd = ":******" } + var delim string + if pwd != "" || u.User != "" { + delim = "@" + } - return fmt.Sprintf("%s://%s%s@%s%s", u.Scheme, u.User, pwd, u.HostPort(), u.Root) + return scheme + u.User + pwd + delim + u.HostPort() + u.Root } func (u *Url) HostPort() string { -- cgit v1.2.3-70-g09d2