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

Function sanitizeGitUrl

packages/worker-utils/src/git-url.ts:57–75  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

55 * if you want to reject malformed URLs.
56 */
57export function sanitizeGitUrl(url: string): string {
58 const sshMatch = url.match(/^git@([^:]+):(.+)$/);
59 if (sshMatch) {
60 const host = sshMatch[1];
61 const path = sshMatch[2].split('?')[0];
62 return `git@${host}:${path}`;
63 }
64
65 try {
66 const parsed = new URL(url);
67 parsed.username = '';
68 parsed.password = '';
69 parsed.search = '';
70 parsed.hash = '';
71 return parsed.toString();
72 } catch {
73 return url;
74 }
75}
76
77/**
78 * Parse a git URL into platform/owner/repo coordinates. Supports HTTPS and

Callers 5

pushToRemoteMethod · 0.90
git-url.test.tsFile · 0.85

Calls 1

toStringMethod · 0.65

Tested by

no test coverage detected