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

Function coordinatesFromHostAndPath

packages/worker-utils/src/git-url.ts:118–146  ·  view source on GitHub ↗
(
  host: string,
  fullPath: string,
  gitlabInstanceUrl?: string
)

Source from the content-addressed store, hash-verified

116}
117
118function coordinatesFromHostAndPath(
119 host: string,
120 fullPath: string,
121 gitlabInstanceUrl?: string
122): RepoCoordinates | null {
123 if (host === 'github.com') {
124 // GitHub clone URLs always have exactly two segments (owner/repo).
125 const parts = fullPath.split('/');
126 if (parts.length >= 2) {
127 return { platform: 'github', owner: parts[0], repo: parts[1] };
128 }
129 return null;
130 }
131
132 if (isGitLabHost(host, gitlabInstanceUrl)) {
133 // GitLab supports subgroups; owner is everything except the last segment.
134 const lastSlash = fullPath.lastIndexOf('/');
135 if (lastSlash > 0) {
136 return {
137 platform: 'gitlab',
138 owner: fullPath.slice(0, lastSlash),
139 repo: fullPath.slice(lastSlash + 1),
140 };
141 }
142 return null;
143 }
144
145 return null;
146}
147
148/**
149 * Compose a `${owner}/${repo}` string suitable for repo-binding lookups.

Callers 1

parseGitUrlFunction · 0.85

Calls 1

isGitLabHostFunction · 0.85

Tested by

no test coverage detected