(repoUrl: string)
| 17 | * - https://github.com/user/repo -> repo |
| 18 | */ |
| 19 | export function extractRepoNameFromUrl(repoUrl: string): string { |
| 20 | // Remove .git suffix if present |
| 21 | let cleanUrl = repoUrl.endsWith('.git') ? repoUrl.slice(0, -4) : repoUrl |
| 22 | |
| 23 | // Handle SSH format: git@github.com:user/repo |
| 24 | if (cleanUrl.includes('@') && cleanUrl.includes(':')) { |
| 25 | cleanUrl = cleanUrl.split(':')[1] |
| 26 | } |
| 27 | |
| 28 | // Handle HTTPS format: https://github.com/user/repo |
| 29 | if (cleanUrl.includes('://')) { |
| 30 | cleanUrl = cleanUrl.split('://')[1] |
| 31 | } |
| 32 | |
| 33 | // Remove domain and get the last part (repo name) |
| 34 | const parts = cleanUrl.split('/') |
| 35 | return parts[parts.length - 1] |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Executes a git command with retry logic and exponential backoff |
no outgoing calls
no test coverage detected