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)
| 161 | // of a single one. |
| 162 | // i.e. path/to/file will return {"path", "path/to", "path/to/file"} |
| 163 | func 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 |
no outgoing calls