MCPcopy Index your code
hub / github.com/OpenListTeam/OpenList / EncodePath

Function EncodePath

pkg/utils/path.go:58–79  ·  view source on GitHub ↗
(path string, all ...bool)

Source from the content-addressed store, hash-verified

56}
57
58func EncodePath(path string, all ...bool) string {
59 seg := strings.Split(path, "/")
60 toReplace := []struct {
61 Src string
62 Dst string
63 }{
64 {Src: "%", Dst: "%25"},
65 {"%", "%25"},
66 {"?", "%3F"},
67 {"#", "%23"},
68 }
69 for i := range seg {
70 if len(all) > 0 && all[0] {
71 seg[i] = url.PathEscape(seg[i])
72 } else {
73 for j := range toReplace {
74 seg[i] = strings.ReplaceAll(seg[i], toReplace[j].Src, toReplace[j].Dst)
75 }
76 }
77 }
78 return strings.Join(seg, "/")
79}
80
81func JoinBasePath(basePath, reqPath string) (string, error) {
82 isRelativePath := strings.Contains(reqPath, "..")

Callers 15

ExtractMethod · 0.92
ExtractMethod · 0.92
ListMethod · 0.92
drivePathAPIURLMethod · 0.92
LinkMethod · 0.92
ExtractMethod · 0.92
GetMetaUrlMethod · 0.92
getProxyLinkMethod · 0.92
FileInfoToObjMethod · 0.92
GetMetaUrlMethod · 0.92
LinkMethod · 0.92
RemoveMethod · 0.92

Calls

no outgoing calls

Tested by 1

TestEncodePathFunction · 0.68