mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 00:04:19 +00:00
internal: accomodate for trailign slashes in Multistatus.Get
This commit is contained in:
parent
7f285fdf83
commit
0b2d0a706c
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user