@@ -20,6 +20,10 @@ export interface AzureDevOpsRemoteInfo {
2020 repo : string ;
2121}
2222
23+ function stripGitSuffix ( repo : string ) : string {
24+ return repo . length > 4 && repo . toLowerCase ( ) . endsWith ( '.git' ) ? repo . slice ( 0 , - 4 ) : repo ;
25+ }
26+
2327/**
2428 * Parse a GitHub remote URL into owner/repo.
2529 * Supports HTTPS and SSH formats:
@@ -37,9 +41,9 @@ export function parseGitHubRemote(url: string): GitHubRemoteInfo | null {
3741 }
3842
3943 // SSH: git@github.com:owner/repo.git
40- const sshMatch = url . match ( / g i t h u b \. c o m : ( [ ^ / ] + ) \/ ( [ ^ / ] + ? ) (?: \. g i t ) ? $ / i) ;
44+ const sshMatch = url . match ( / ^ (?: [ ^ @ \s / : ] + @ ) ? g i t h u b \. c o m : ( [ ^ / ] + ) \/ ( [ ^ / ] + ) $ / i) ;
4145 if ( sshMatch ) {
42- return { owner : sshMatch [ 1 ] ! , repo : sshMatch [ 2 ] ! } ;
46+ return { owner : sshMatch [ 1 ] ! , repo : stripGitSuffix ( sshMatch [ 2 ] ! ) } ;
4347 }
4448
4549 return null ;
@@ -91,10 +95,10 @@ export function parseAzureDevOpsRemote(url: string): AzureDevOpsRemoteInfo | nul
9195 // (Org subdomain keeps the no-dot constraint — the `.visualstudio.com` anchor
9296 // requires it. Only the repo capture is widened.)
9397 const vsMatch = url . match (
94- / ( [ ^ / . ] + ) \. v i s u a l s t u d i o \. c o m \/ ( [ ^ / ] + ) \/ _ g i t \/ ( [ ^ / ] + ? ) (?: \. g i t ) ? $ / i,
98+ / ^ (?: h t t p s ? | s s h | g i t ) : \/ \/ ( [ ^ / . ] + ) \. v i s u a l s t u d i o \. c o m \/ ( [ ^ / ] + ) \/ _ g i t \/ ( [ ^ / ] + ) $ / i,
9599 ) ;
96100 if ( vsMatch ) {
97- return { org : decodeSegment ( vsMatch [ 1 ] ! ) , project : decodeSegment ( vsMatch [ 2 ] ! ) , repo : decodeSegment ( vsMatch [ 3 ] ! ) } ;
101+ return { org : decodeSegment ( vsMatch [ 1 ] ! ) , project : decodeSegment ( vsMatch [ 2 ] ! ) , repo : decodeSegment ( stripGitSuffix ( vsMatch [ 3 ] ! ) ) } ;
98102 }
99103
100104 return null ;
0 commit comments