(url: string)
| 152 | * @returns Repository name or undefined |
| 153 | */ |
| 154 | export function extractRepositoryName(url: string): string { |
| 155 | try { |
| 156 | // Handle different URL formats |
| 157 | const patterns = [ |
| 158 | // HTTPS: https://github.com/user/repo.git -> user/repo |
| 159 | /https:\/\/[^\/]+\/([^\/]+\/[^\/]+?)(?:\.git)?$/, |
| 160 | // SSH: git@github.com:user/repo.git -> user/repo |
| 161 | /git@[^:]+:([^\/]+\/[^\/]+?)(?:\.git)?$/, |
| 162 | // SSH with user: ssh://git@github.com/user/repo.git -> user/repo |
| 163 | /ssh:\/\/[^\/]+\/([^\/]+\/[^\/]+?)(?:\.git)?$/, |
| 164 | ] |
| 165 | |
| 166 | for (const pattern of patterns) { |
| 167 | const match = url.match(pattern) |
| 168 | if (match && match[1]) { |
| 169 | return match[1].replace(/\.git$/, "") |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | return "" |
| 174 | } catch { |
| 175 | return "" |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Gets git repository information for the current VSCode workspace |
no test coverage detected