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

Function validateGitUrl

source code/utils/plugins/pluginLoader.ts:472–489  ·  view source on GitHub ↗

* Validate a git URL using Node.js URL parsing

(url: string)

Source from the content-addressed store, hash-verified

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