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

Function FixAndCleanPath

pkg/utils/path.go:19–25  ·  view source on GitHub ↗

FixAndCleanPath The upper layer of the root directory is still the root directory. So ".." And "." will be cleared for example 1. ".." or "." => "/" 2. "../..." or "./..." => "/..." 3. "../.x." or "./.x." => "/.x." 4. "x//\\y" = > "/z/x"

(path string)

Source from the content-addressed store, hash-verified

17// 3. "../.x." or "./.x." => "/.x."
18// 4. "x//\\y" = > "/z/x"
19func FixAndCleanPath(path string) string {
20 path = strings.ReplaceAll(path, "\\", "/")
21 if !strings.HasPrefix(path, "/") {
22 path = "/" + path
23 }
24 return stdpath.Clean(path)
25}
26
27// PathAddSeparatorSuffix Add path '/' suffix
28// for example /root => /root/

Callers 15

LinkMethod · 0.92
ExtractMethod · 0.92
InitMethod · 0.92
InitMethod · 0.92
drivePathAPIURLMethod · 0.92
InitMethod · 0.92
toModelObjMethod · 0.92
toModelObjMethod · 0.92
InitMethod · 0.92
getContentApiUrlMethod · 0.92
getPathCommonAncestorFunction · 0.92

Calls

no outgoing calls

Tested by 1

TestFixAndCleanPathFunction · 0.68