2022-08-11 12:32:17 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestEncodePath(t *testing.T) {
|
|
|
|
t.Log(EncodePath("http://localhost:5244/d/123#.png"))
|
|
|
|
}
|
2022-12-17 11:49:05 +00:00
|
|
|
|
|
|
|
func TestFixAndCleanPath(t *testing.T) {
|
|
|
|
datas := map[string]string{
|
|
|
|
"": "/",
|
|
|
|
".././": "/",
|
|
|
|
"../../.../": "/...",
|
|
|
|
"x//\\y/": "/x/y",
|
|
|
|
".././.x/.y/.//..x../..y..": "/.x/.y/..x../..y..",
|
|
|
|
}
|
|
|
|
for key, value := range datas {
|
|
|
|
if FixAndCleanPath(key) != value {
|
|
|
|
t.Logf("raw %s fix fail", key)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|