MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / validateGitUrl

Function validateGitUrl

src/utils/plugins/pluginLoader.ts:471–488  ·  view source on GitHub ↗

* Validate a git URL using Node.js URL parsing

(url: string)

Source from the content-addressed store, hash-verified

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