MCPcopy Index your code
hub / github.com/docker/cli / parseUNCPath

Function parseUNCPath

cli/command/telemetry_docker.go:185–213  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

183}
184
185func parseUNCPath(s string) (drive, p string, ok bool) {
186 // UNC paths use backslashes but we're using forward slashes
187 // so also enforce that here.
188 //
189 // In reality, this should have been enforced much earlier
190 // than here since backslashes aren't allowed in URLs, but
191 // we're going to code defensively here.
192 s = filepath.ToSlash(s)
193
194 const uncPrefix = "//./"
195 if !strings.HasPrefix(s, uncPrefix) {
196 // Not a UNC path.
197 return "", "", false
198 }
199 s = s[len(uncPrefix):]
200
201 parts := strings.SplitN(s, "/", 2)
202 if len(parts) != 2 {
203 // Not enough components.
204 return "", "", false
205 }
206
207 drive, ok = splitWindowsDrive(parts[0])
208 if !ok {
209 // Not a windows drive.
210 return "", "", false
211 }
212 return drive, "/" + parts[1], true
213}
214
215// splitWindowsDrive checks if the string references a windows
216// drive (such as c:) and returns the drive letter if it is.

Callers 1

toWslPathFunction · 0.85

Calls 1

splitWindowsDriveFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…