MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / parseGitHubRepository

Function parseGitHubRepository

source code/utils/detectRepository.ts:134–163  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

132 * Also accepts plain "owner/repo" strings for backward compatibility.
133 */
134export function parseGitHubRepository(input: string): string | null {
135 const trimmed = input.trim()
136
137 // Try parsing as a full remote URL first.
138 // Only return results for github.com hosts — existing callers (VS Code extension,
139 // bridge) assume this function is GitHub.com-specific. Use parseGitRemote() directly
140 // for GHE support.
141 const parsed = parseGitRemote(trimmed)
142 if (parsed) {
143 if (parsed.host !== 'github.com') return null
144 return `${parsed.owner}/${parsed.name}`
145 }
146
147 // If no URL pattern matched, check if it's already in owner/repo format
148 if (
149 !trimmed.includes('://') &&
150 !trimmed.includes('@') &&
151 trimmed.includes('/')
152 ) {
153 const parts = trimmed.split('/')
154 if (parts.length === 2 && parts[0] && parts[1]) {
155 // Remove .git extension if present
156 const repo = parts[1].replace(/\.git$/, '')
157 return `${parts[0]}/${repo}`
158 }
159 }
160
161 logForDebugging(`Could not parse repository from: ${trimmed}`)
162 return null
163}
164
165/**
166 * Checks whether a hostname looks like a real domain name rather than an

Callers 5

validateRepoAtPathFunction · 0.85
createBridgeSessionFunction · 0.85
bridgeMainFunction · 0.85

Calls 2

parseGitRemoteFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected