diff --git a/client.go b/client.go index ec99a0f..a2543d1 100644 --- a/client.go +++ b/client.go @@ -69,7 +69,7 @@ func getProps(r *response, status string) *props { } func (c *Client) ReadDir(path string) ([]os.FileInfo, error) { - path = FixSlash(path) + path = FixSlashes(path) files := make([]os.FileInfo, 0) skipSelf := true parse := func(resp interface{}) { diff --git a/main/client.go b/main/client.go index 499ee8f..900a5f5 100644 --- a/main/client.go +++ b/main/client.go @@ -39,7 +39,7 @@ func main() { switch *m { case "LIST", "PROPFIND": if files, err := c.ReadDir(path); err == nil { - fmt.Println(len(files)) + fmt.Println(fmt.Sprintf("Resources: %d - %s", len(files), path)) for _, f := range files { fmt.Println(f) } diff --git a/utils.go b/utils.go index ea2e053..c992869 100644 --- a/utils.go +++ b/utils.go @@ -23,6 +23,13 @@ func FixSlash(s string) string { return s } +func FixSlashes(s string) string { + if s[0] != '/' { + s = "/" + s + } + return FixSlash(s) +} + func Join(path0 string, path1 string) string { return strings.TrimSuffix(path0, "/") + "/" + strings.TrimPrefix(path1, "/") }