mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-08 19:40:25 +08:00
反向代理支持RequestPath、RequestURI等
This commit is contained in:
24
internal/utils/path.go
Normal file
24
internal/utils/path.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package utils
|
||||
|
||||
// 清理Path中的多余的字符
|
||||
func CleanPath(path string) string {
|
||||
l := len(path)
|
||||
if l == 0 {
|
||||
return "/"
|
||||
}
|
||||
result := []byte{'/'}
|
||||
isSlash := true
|
||||
for i := 0; i < l; i++ {
|
||||
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