MCPcopy Create free account
hub / github.com/cli/cli / isRelativePath

Function isRelativePath

internal/attachments/references.go:396–401  ·  view source on GitHub ↗

isRelativePath reports whether path is relative to a directory, and so can be placed inside the one the markdown was read from. filepath.IsAbs is not enough on Windows, where "\x" is rooted on the current drive and "C:x" names a drive of its own, though neither is absolute.

(path string)

Source from the content-addressed store, hash-verified

394// enough on Windows, where "\x" is rooted on the current drive and "C:x" names
395// a drive of its own, though neither is absolute.
396func isRelativePath(path string) bool {
397 if path == "" || filepath.IsAbs(path) || filepath.VolumeName(path) != "" {
398 return false
399 }
400 return !os.IsPathSeparator(path[0])
401}
402
403// isRemoteDestination reports whether a destination addresses somewhere other
404// than the filesystem, so that an attached file is never confused with a URI.

Callers 2

TestIsRelativePathFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestIsRelativePathFunction · 0.68