internal: fix trailing slash getting removed in Client.ResolveHref

This commit is contained in:
Simon Ser 2020-02-12 16:40:03 +01:00
parent 1d93353e3d
commit 9afa59dc22
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -36,11 +36,17 @@ func (c *Client) SetBasicAuth(username, password string) {
}
func (c *Client) ResolveHref(p string) *url.URL {
trailingSlash := strings.HasSuffix(p, "/")
p = path.Join(c.endpoint.Path, p)
// path.Join trims any trailing slash
if trailingSlash {
p += "/"
}
return &url.URL{
Scheme: c.endpoint.Scheme,
User: c.endpoint.User,
Host: c.endpoint.Host,
Path: path.Join(c.endpoint.Path, p),
Path: p,
}
}