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)
| 17 | // 3. "../.x." or "./.x." => "/.x." |
| 18 | // 4. "x//\\y" = > "/z/x" |
| 19 | func 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/ |
no outgoing calls