diff --git a/package-lock.json b/package-lock.json index e58ca60..d446e1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "codeant-cli", - "version": "0.4.12", + "version": "0.4.13", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "codeant-cli", - "version": "0.4.12", + "version": "0.4.13", "license": "MIT", "dependencies": { "@gitbeaker/rest": "^43.8.0", diff --git a/package.json b/package.json index 366663c..fa2f32e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codeant-cli", - "version": "0.4.12", + "version": "0.4.13", "description": "Code review CLI tool", "type": "module", "bin": { diff --git a/src/scm/index.js b/src/scm/index.js index 3329ae1..9cb4172 100644 --- a/src/scm/index.js +++ b/src/scm/index.js @@ -65,10 +65,13 @@ export function detectRemote() { export function detectRepoName() { const origin = getOrigin(); if (!origin) return null; - // Handle SSH: git@github.com:owner/repo.git - // Handle HTTPS: https://github.com/owner/repo.git - const match = origin.match(/[/:]([\w.-]+(?:\/[\w.-]+)+?)(?:\.git)?$/); - return match ? match[1] : null; + // SSH: git@host:path/to/repo[.git] + const sshMatch = origin.match(/^(?:[^@]+@)?[^:]+:(.+?)(?:\.git)?$/); + if (sshMatch) return sshMatch[1]; + // HTTPS: https://[user:pass@]host/path/to/repo[.git] + const httpsMatch = origin.match(/^(?:https?|git):\/\/[^/]+\/(.+?)(?:\.git)?$/); + if (httpsMatch) return httpsMatch[1]; + return null; } // Auto-detect default branch