MCPcopy Index your code
hub / github.com/devspace-sh/devspace / stripPathShortcuts

Function stripPathShortcuts

pkg/devspace/hook/download.go:183–202  ·  view source on GitHub ↗

stripPathShortcuts removes any leading or trailing "../" from a given path

(p string)

Source from the content-addressed store, hash-verified

181
182// stripPathShortcuts removes any leading or trailing "../" from a given path
183func stripPathShortcuts(p string) string {
184 newPath := path.Clean(p)
185 trimmed := strings.TrimPrefix(newPath, "../")
186
187 for trimmed != newPath {
188 newPath = trimmed
189 trimmed = strings.TrimPrefix(newPath, "../")
190 }
191
192 // trim leftover {".", ".."}
193 if newPath == "." || newPath == ".." {
194 newPath = ""
195 }
196
197 if len(newPath) > 0 && string(newPath[0]) == "/" {
198 return newPath[1:]
199 }
200
201 return newPath
202}

Callers 2

downloadFunction · 0.85
isDestRelativeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected