MCPcopy Index your code
hub / github.com/modelcontextprotocol/registry / IsValidSubfolderPath

Function IsValidSubfolderPath

internal/validators/utils.go:100–132  ·  view source on GitHub ↗

IsValidSubfolderPath checks if a subfolder path is valid

(path string)

Source from the content-addressed store, hash-verified

98
99// IsValidSubfolderPath checks if a subfolder path is valid
100func IsValidSubfolderPath(path string) bool {
101 // Empty path is valid (subfolder is optional)
102 if path == "" {
103 return true
104 }
105
106 // Must not start with / (must be relative)
107 if strings.HasPrefix(path, "/") {
108 return false
109 }
110
111 // Must not end with / (clean path format)
112 if strings.HasSuffix(path, "/") {
113 return false
114 }
115
116 // Check for valid path characters (alphanumeric, dash, underscore, dot, forward slash)
117 validPathRegex := regexp.MustCompile(`^[a-zA-Z0-9\-_./]+$`)
118 if !validPathRegex.MatchString(path) {
119 return false
120 }
121
122 // Check that path segments are valid
123 segments := strings.Split(path, "/")
124 for _, segment := range segments {
125 // Disallow empty segments ("//"), current dir ("."), and parent dir ("..")
126 if segment == "" || segment == "." || segment == ".." {
127 return false
128 }
129 }
130
131 return true
132}
133
134// IsValidRemoteURL checks if a URL is valid for remotes (stricter than packages - no localhost allowed)
135func IsValidRemoteURL(rawURL string) bool {

Callers 1

validateRepositoryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…