mirror of https://github.com/Xhofe/alist
fix: path `IsApply` check (close #3784)
parent
02d0aef611
commit
43de823058
|
@ -20,7 +20,7 @@ func IsApply(metaPath, reqPath string, applySub bool) bool {
|
|||
if utils.PathEqual(metaPath, reqPath) {
|
||||
return true
|
||||
}
|
||||
return utils.IsSubPath(reqPath, metaPath) && applySub
|
||||
return utils.IsSubPath(metaPath, reqPath) && applySub
|
||||
}
|
||||
|
||||
func CanAccess(user *model.User, meta *model.Meta, reqPath string, password string) bool {
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package common
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestIsApply(t *testing.T) {
|
||||
datas := []struct {
|
||||
metaPath string
|
||||
reqPath string
|
||||
applySub bool
|
||||
result bool
|
||||
}{
|
||||
{
|
||||
metaPath: "/",
|
||||
reqPath: "/test",
|
||||
applySub: true,
|
||||
result: true,
|
||||
},
|
||||
}
|
||||
for i, data := range datas {
|
||||
if IsApply(data.metaPath, data.reqPath, data.applySub) != data.result {
|
||||
t.Errorf("TestIsApply %d failed", i)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue