(url: string)
| 68 | } |
| 69 | |
| 70 | function parseGitUrl(url: string): string | null { |
| 71 | const cleanUrl = url.replace(/\.git$/, ""); |
| 72 | |
| 73 | const host = cleanUrl |
| 74 | .replace(/^[a-z][a-z0-9+.-]*:\/\//i, "") // strip scheme:// |
| 75 | .replace(/^[^@/]+@/, "") // strip user@ |
| 76 | .split(/[/:]/)[0] // host token, before first / or : |
| 77 | .toLowerCase(); |
| 78 | |
| 79 | let platform: string | null = null; |
| 80 | if (host === "github.com" || host.endsWith(".github.com")) { |
| 81 | platform = "github"; |
| 82 | } else if (host === "gitlab.com" || host.endsWith(".gitlab.com")) { |
| 83 | platform = "gitlab"; |
| 84 | } else if (host === "bitbucket.org" || host.endsWith(".bitbucket.org")) { |
| 85 | platform = "bitbucket"; |
| 86 | } |
| 87 | |
| 88 | const sshMatch = cleanUrl.match(/[@:]([^:/@]+\/[^:/@]+)$/); |
| 89 | const httpsMatch = cleanUrl.match(/\/([^/]+\/[^/]+)$/); |
| 90 | |
| 91 | const repoPath = sshMatch?.[1] || httpsMatch?.[1]; |
| 92 | |
| 93 | if (!repoPath) return null; |
| 94 | |
| 95 | const org = extractOrg(repoPath); |
| 96 | if (!org) return null; |
| 97 | |
| 98 | if (platform) { |
| 99 | return `${platform}:${org}`; |
| 100 | } |
| 101 | |
| 102 | return `git:${org}`; |
| 103 | } |
no test coverage detected