(input: string)
| 276 | * Handles: git+https://, git://, git@host:path, ssh://git@host/path |
| 277 | */ |
| 278 | export function normalizeGitUrl(input: string): string | null { |
| 279 | const url = input |
| 280 | .trim() |
| 281 | .replace(/^git\+/, '') |
| 282 | .replace(/\.git(?=[/#?]|$)/i, '') |
| 283 | .replace(/(^|\/)[^/]+?@/, '$1') // remove "user@" from "ssh://user@host.com:..." |
| 284 | .replace(/(\.[^./]+?):/, '$1/') // change ".com:" to ".com/" from "ssh://user@host.com:..." |
| 285 | .replace(/^git:\/\//, 'https://') |
| 286 | .replace(/^ssh:\/\//, 'https://') |
| 287 | if (!url) return null |
| 288 | return url.includes('://') ? url : `https://${url}` |
| 289 | } |
| 290 | |
| 291 | export function parseRepoUrl(input: string): RepoRef | null { |
| 292 | const normalized = normalizeGitUrl(input) |
no outgoing calls
no test coverage detected