From 0b2d0a706cfcc0f0eeb3bd4c4a55020d9e63f64a Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 12 Feb 2020 17:12:21 +0100 Subject: [PATCH] internal: accomodate for trailign slashes in Multistatus.Get --- internal/elements.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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