优化代码

This commit is contained in:
刘祥超
2023-08-08 15:12:28 +08:00
parent 3c5c961cd5
commit 6a2803187e
21 changed files with 61 additions and 78 deletions

View File

@@ -71,29 +71,3 @@ func (this *HTTPAuthBaseMethod) MatchRequest(req *http.Request) bool {
return true
}
// cleanPath 清理Path中的多余的字符
func (this *HTTPAuthBaseMethod) cleanPath(path string) string {
var l = len(path)
if l == 0 {
return "/"
}
var result = []byte{'/'}
var isSlash = true
for i := 0; i < l; i++ {
if path[i] == '?' {
result = append(result, path[i:]...)
break
}
if path[i] == '\\' || path[i] == '/' {
if !isSlash {
isSlash = true
result = append(result, '/')
}
} else {
isSlash = false
result = append(result, path[i])
}
}
return string(result)
}