MCPcopy
hub / github.com/AlistGo/alist / JoinBasePath

Function JoinBasePath

pkg/utils/path.go:77–99  ·  view source on GitHub ↗
(basePath, reqPath string)

Source from the content-addressed store, hash-verified

75}
76
77func JoinBasePath(basePath, reqPath string) (string, error) {
78 /** relative path:
79 * 1. ..
80 * 2. ../
81 * 3. /..
82 * 4. /../
83 * 5. /a/b/..
84 */
85 if reqPath == ".." ||
86 strings.HasSuffix(reqPath, "/..") ||
87 strings.HasPrefix(reqPath, "../") ||
88 strings.Contains(reqPath, "/../") {
89 return "", errs.RelativePath
90 }
91
92 reqPath = FixAndCleanPath(reqPath)
93
94 if strings.HasPrefix(reqPath, "/") {
95 return reqPath, nil
96 }
97
98 return stdpath.Join(FixAndCleanPath(basePath), FixAndCleanPath(reqPath)), nil
99}
100
101func GetFullPath(mountPath, path string) string {
102 return stdpath.Join(GetActualMountPath(mountPath), path)

Callers 2

MakeDirMethod · 0.92
JoinPathMethod · 0.92

Calls 2

FixAndCleanPathFunction · 0.85
ContainsMethod · 0.80

Tested by

no test coverage detected