internal: preserve trailing slashes in baseURL and principal path
Closes: https://github.com/emersion/go-webdav/issues/203
This commit is contained in:
parent
1916c2d907
commit
0463911636
@ -110,9 +110,16 @@ func NewClient(c HTTPClient, endpoint string) (*Client, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) ResolveHref(p string) *url.URL {
|
func (c *Client) ResolveHref(p string) *url.URL {
|
||||||
|
hasTrailingSlash := strings.HasSuffix(p, "/") || (p == "" && strings.HasSuffix(c.endpoint.Path, "/"))
|
||||||
|
|
||||||
if !strings.HasPrefix(p, "/") {
|
if !strings.HasPrefix(p, "/") {
|
||||||
p = path.Join(c.endpoint.Path, p)
|
p = path.Join(c.endpoint.Path, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if hasTrailingSlash && !strings.HasSuffix(p, "/") {
|
||||||
|
p += "/"
|
||||||
|
}
|
||||||
|
|
||||||
return &url.URL{
|
return &url.URL{
|
||||||
Scheme: c.endpoint.Scheme,
|
Scheme: c.endpoint.Scheme,
|
||||||
User: c.endpoint.User,
|
User: c.endpoint.User,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user