From 50a02a7af7e8214f39440581287710cf9a08bdbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=AE=E5=87=89?= <927625802@qq.com> Date: Mon, 29 Nov 2021 21:30:52 +0800 Subject: [PATCH] :fire: remove useless code --- server/check.go | 4 ++-- server/webdav/file.go | 2 +- utils/file.go | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/server/check.go b/server/check.go index 399211a0..45c682d1 100644 --- a/server/check.go +++ b/server/check.go @@ -48,7 +48,7 @@ func CheckParent(path string, password string) bool { } return true } else { - if path == "/" || path == "\\" { + if path == "/" { return true } return CheckParent(utils.Dir(path), password) @@ -71,7 +71,7 @@ func CheckDownLink(path string, passwordMd5 string) bool { if !conf.CheckParent { return true } - if path == "/" || path == "\\" { + if path == "/" { return true } return CheckDownLink(utils.Dir(path), passwordMd5) diff --git a/server/webdav/file.go b/server/webdav/file.go index efee9226..2845ccef 100644 --- a/server/webdav/file.go +++ b/server/webdav/file.go @@ -94,7 +94,7 @@ func GetPW(path string) string { if !conf.CheckParent { return "" } - if path == "/" || path == "\\" { + if path == "/" { return "" } return GetPW(utils.Dir(path)) diff --git a/utils/file.go b/utils/file.go index 170b1974..977edbc1 100644 --- a/utils/file.go +++ b/utils/file.go @@ -97,7 +97,12 @@ func RemoveLastSlash(path string) string { } func Dir(path string) string { - path = ParsePath(path) idx := strings.LastIndex(path, "/") + if idx == 0 { + return "/" + } + if idx == -1 { + return path + } return path[:idx] } \ No newline at end of file