MCPcopy Create free account
hub / github.com/ddev/ddev / PathWithSlashesToArray

Function PathWithSlashesToArray

pkg/nodeps/utils.go:163–174  ·  view source on GitHub ↗

PathWithSlashesToArray returns an array of all possible paths separated by slashes out of a single one. i.e. path/to/file will return {"path", "path/to", "path/to/file"}

(path string)

Source from the content-addressed store, hash-verified

161// of a single one.
162// i.e. path/to/file will return {"path", "path/to", "path/to/file"}
163func PathWithSlashesToArray(path string) []string {
164 var paths []string
165 var partial string
166 for p := range strings.SplitSeq(path, "/") {
167 partial += p
168 if len(partial) > 0 {
169 paths = append(paths, partial)
170 }
171 partial += "/"
172 }
173 return paths
174}
175
176// ParseURL parses a URL and returns the scheme, URL without port, and port
177// If the URL doesn't have an explicit port, returns the default port for the scheme

Callers 2

Calls

no outgoing calls

Tested by 1