mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2026-01-03 09:36:35 +08:00
优化代码
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user