diff --git a/internal/elements.go b/internal/elements.go index 856508b..8bf2507 100644 --- a/internal/elements.go +++ b/internal/elements.go @@ -5,6 +5,7 @@ import ( "fmt" "net/http" "net/url" + "path" "strconv" "strings" "time" @@ -98,17 +99,19 @@ func NewMultistatus(resps ...Response) *Multistatus { return &Multistatus{Responses: resps} } -func (ms *Multistatus) Get(path string) (*Response, error) { +func (ms *Multistatus) Get(p string) (*Response, error) { + // Clean the path to avoid issues with trailing slashes + p = path.Clean(p) for i := range ms.Responses { resp := &ms.Responses[i] for _, h := range resp.Hrefs { - if h.Path == path { + if path.Clean(h.Path) == p { return resp, resp.Status.Err() } } } - return nil, fmt.Errorf("webdav: missing response for path %q", path) + return nil, fmt.Errorf("webdav: missing response for path %q", p) } // https://tools.ietf.org/html/rfc4918#section-14.24