@@ -2,6 +2,7 @@ package op
22
33import (
44 "github.com/alist-org/alist/v3/internal/errs"
5+ stdpath "path"
56 "strings"
67
78 "github.com/alist-org/alist/v3/internal/driver"
@@ -27,3 +28,30 @@ func GetStorageAndActualPath(rawPath string) (storage driver.Driver, actualPath
2728 actualPath = utils .FixAndCleanPath (strings .TrimPrefix (rawPath , mountPath ))
2829 return
2930}
31+
32+ // urlTreeSplitLineFormPath 分割path中分割真实路径和UrlTree定义字符串
33+ func urlTreeSplitLineFormPath (path string ) (pp string , file string ) {
34+ // url.PathUnescape 会移除 // ,手动加回去
35+ path = strings .Replace (path , "https:/" , "https://" , 1 )
36+ path = strings .Replace (path , "http:/" , "http://" , 1 )
37+ if strings .Contains (path , ":https:/" ) || strings .Contains (path , ":http:/" ) {
38+ // URL-Tree模式 /url_tree_drivr/file_name[:size[:time]]:https://example.com/file
39+ fPath := strings .SplitN (path , ":" , 2 )[0 ]
40+ pp , _ = stdpath .Split (fPath )
41+ file = path [len (pp ):]
42+ } else if strings .Contains (path , "/https:/" ) || strings .Contains (path , "/http:/" ) {
43+ // URL-Tree模式 /url_tree_drivr/https://example.com/file
44+ index := strings .Index (path , "/http://" )
45+ if index == - 1 {
46+ index = strings .Index (path , "/https://" )
47+ }
48+ pp = path [:index ]
49+ file = path [index + 1 :]
50+ } else {
51+ pp , file = stdpath .Split (path )
52+ }
53+ if pp == "" {
54+ pp = "/"
55+ }
56+ return
57+ }
0 commit comments