MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / sanitizeGitUrl

Function sanitizeGitUrl

src/utils/git.ts:125–147  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

123 * @returns Sanitized URL
124 */
125export function sanitizeGitUrl(url: string): string {
126 try {
127 // Remove credentials from HTTPS URLs
128 if (url.startsWith("https://")) {
129 const urlObj = new URL(url)
130 // Remove username and password
131 urlObj.username = ""
132 urlObj.password = ""
133 return urlObj.toString()
134 }
135
136 // For SSH URLs, return as-is (they don't contain sensitive tokens)
137 if (url.startsWith("git@") || url.startsWith("ssh://")) {
138 return url
139 }
140
141 // For other formats, return as-is but remove any potential tokens
142 return url.replace(/:[a-f0-9]{40,}@/gi, "@")
143 } catch {
144 // If URL parsing fails, return original (might be SSH format)
145 return url
146 }
147}
148
149/**
150 * Extracts repository name from a git URL

Callers 2

git.spec.tsFile · 0.90
getGitRepositoryInfoFunction · 0.85

Calls 2

toStringMethod · 0.65
replaceMethod · 0.65

Tested by

no test coverage detected