@@ -4,7 +4,10 @@ import {color} from '../Style/color';
44
55class _GitHubUtil {
66 getInfo ( url : string ) : { repo : string ; issueNumber : number , user : string , repoOrg : string , repoName : string } {
7- const urlPaths = url . split ( '/' ) . reverse ( ) ;
7+ const urlObj = new URL ( url ) ;
8+ const pathname = urlObj . pathname ;
9+
10+ const urlPaths = pathname . split ( '/' ) . reverse ( ) ;
811 const repoOrg = urlPaths [ 3 ] ;
912 const repoName = urlPaths [ 2 ] ;
1013 const repo = `${ repoOrg } /${ repoName } ` ;
@@ -30,16 +33,22 @@ class _GitHubUtil {
3033 isIssueUrl ( host : string , url : string ) : boolean {
3134 if ( ! url ) return false ;
3235
33- let isIssue = ! ! url . match ( new RegExp ( `^https://${ host } /[\\w\\d-_.]+/[\\w\\d-_.]+/issues/\\d+$` ) ) ;
34- let isPR = ! ! url . match ( new RegExp ( `^https://${ host } /[\\w\\d-_.]+/[\\w\\d-_.]+/pull/\\d+$` ) ) ;
36+ const urlObj = new URL ( url ) ;
37+ if ( urlObj . host !== host ) return false ;
38+
39+ const isIssue = ! ! urlObj . pathname . match ( new RegExp ( `^/[\\w\\d-_.]+/[\\w\\d-_.]+/issues/\\d+$` ) ) ;
40+ const isPR = ! ! urlObj . pathname . match ( new RegExp ( `^/[\\w\\d-_.]+/[\\w\\d-_.]+/pull/\\d+$` ) ) ;
3541
3642 return isIssue || isPR ;
3743 }
3844
3945 isProjectUrl ( host : string , url : string ) : boolean {
4046 if ( ! url ) return false ;
4147
42- return ! ! url . match ( new RegExp ( `^https://${ host } /[\\w\\d-_.]+/[\\w\\d-_.]+/projects/\\d+$` ) ) ;
48+ const urlObj = new URL ( url ) ;
49+ if ( urlObj . host !== host ) return false ;
50+
51+ return ! ! urlObj . pathname . match ( new RegExp ( `^/[\\w\\d-_.]+/[\\w\\d-_.]+/projects/\\d+$` ) ) ;
4352 }
4453
4554 getIssueTypeInfo ( issue : IssueEntity ) : { icon : IconNameType ; color : string ; label : string , state : string } {
0 commit comments