MCPcopy Index your code
hub / github.com/jetify-com/devbox / isSSHURL

Function isSSHURL

internal/plugin/git.go:152–167  ·  view source on GitHub ↗

isSSHURL checks if the given URL is an SSH URL. SSH URLs can be in formats: - ssh://user@host/path - git@host:path - ssh://git@host/path

(url string)

Source from the content-addressed store, hash-verified

150// - git@host:path
151// - ssh://git@host/path
152func isSSHURL(url string) bool {
153 url = strings.TrimSpace(url)
154 // Check for explicit ssh:// protocol
155 if strings.HasPrefix(url, "ssh://") {
156 return true
157 }
158 // Check for git@host:path format (SCP-like syntax)
159 // This format uses colon after host, not port number
160 if strings.HasPrefix(url, "git@") && strings.Contains(url, ":") {
161 // Make sure it's not an HTTPS URL with port (e.g., https://git@host:443/path)
162 if !strings.HasPrefix(url, "http://") && !strings.HasPrefix(url, "https://") {
163 return true
164 }
165 }
166 return false
167}
168
169func isBranchName(ref string) bool {
170 // Full commit hashes are 40 hex characters

Callers 2

cloneAndReadMethod · 0.85
TestIsSSHURLFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestIsSSHURLFunction · 0.68