MCPcopy Index your code
hub / github.com/codeaashu/claude-code / validateGitUrl

Function validateGitUrl

src/utils/plugins/pluginLoader.ts:470–487  ·  view source on GitHub ↗

* Validate a git URL using Node.js URL parsing

(url: string)

Source from the content-addressed store, hash-verified

468 * Validate a git URL using Node.js URL parsing
469 */
470function validateGitUrl(url: string): string {
471 try {
472 const parsed = new URL(url)
473 if (!['https:', 'http:', 'file:'].includes(parsed.protocol)) {
474 if (!/^git@[a-zA-Z0-9.-]+:/.test(url)) {
475 throw new Error(
476 `Invalid git URL protocol: ${parsed.protocol}. Only HTTPS, HTTP, file:// and SSH (git@) URLs are supported.`,
477 )
478 }
479 }
480 return url
481 } catch {
482 if (/^git@[a-zA-Z0-9.-]+:/.test(url)) {
483 return url
484 }
485 throw new Error(`Invalid git URL: ${url}`)
486 }
487}
488
489/**
490 * Install a plugin from npm using a global cache (exported for testing)

Callers 2

installFromGitFunction · 0.85
resolveGitSubdirUrlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected