MCPcopy
hub / github.com/opentrace/opentrace / normalizeRepoUrl

Function normalizeRepoUrl

ui/src/components/indexing/urlNormalize.ts:32–53  ·  view source on GitHub ↗
(raw: string)

Source from the content-addressed store, hash-verified

30 * - HTTPS/other: passed through unchanged (with .git suffix stripped)
31 */
32export function normalizeRepoUrl(raw: string): string {
33 const trimmed = raw.trim();
34
35 // SCP-style: git@github.com:owner/repo.git
36 const scpMatch = trimmed.match(/^[\w.-]+@([^:]+):(.+)$/);
37 if (scpMatch) {
38 const host = scpMatch[1];
39 const path = stripDotGit(scpMatch[2]);
40 return `https://${host}/${path}`;
41 }
42
43 // SSH protocol: ssh://git@github.com/owner/repo.git
44 const sshMatch = trimmed.match(/^ssh:\/\/[\w.-]+@([^/]+)\/(.+)$/);
45 if (sshMatch) {
46 const host = sshMatch[1];
47 const path = stripDotGit(sshMatch[2]);
48 return `https://${host}/${path}`;
49 }
50
51 // Everything else: strip .git suffix if present, pass through
52 return stripDotGit(trimmed);
53}
54
55function stripDotGit(s: string): string {
56 return s.endsWith('.git') ? s.slice(0, -4) : s;

Callers 2

AppInnerFunction · 0.90
GraphViewer.tsxFile · 0.90

Calls 1

stripDotGitFunction · 0.70

Tested by

no test coverage detected