MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / parseGitUrl

Function parseGitUrl

packages/worker-utils/src/git-url.ts:86–102  ·  view source on GitHub ↗
(gitUrl: string, gitlabInstanceUrl?: string)

Source from the content-addressed store, hash-verified

84 * `repo` set to the final path segment.
85 */
86export function parseGitUrl(gitUrl: string, gitlabInstanceUrl?: string): RepoCoordinates | null {
87 // Normalize: strip trailing .git and embedded credentials (e.g. https://token@github.com/...)
88 const withoutGitSuffix = gitUrl.endsWith('.git') ? gitUrl.slice(0, -4) : gitUrl;
89 const url = stripEmbeddedCredentials(withoutGitSuffix);
90
91 const httpsMatch = url.match(/^https?:\/\/([^/]+)\/(.+)/);
92 if (httpsMatch) {
93 return coordinatesFromHostAndPath(httpsMatch[1], httpsMatch[2], gitlabInstanceUrl);
94 }
95
96 const sshMatch = url.match(/^git@([^:]+):(.+)/);
97 if (sshMatch) {
98 return coordinatesFromHostAndPath(sshMatch[1], sshMatch[2], gitlabInstanceUrl);
99 }
100
101 return null;
102}
103
104function stripEmbeddedCredentials(url: string): string {
105 const authorityMarker = '//';

Callers 5

createConvoyBranchFunction · 0.90
applyActionFunction · 0.90
repoFullNameFromGitUrlFunction · 0.85
git-url.test.tsFile · 0.85

Calls 2

stripEmbeddedCredentialsFunction · 0.85

Tested by

no test coverage detected