let ISSUE_CLOSING_KEYWORDS = [ 'close' , 'closes' , 'closed' , 'fix' , 'fixes' , 'fixed' , 'resolve' , 'resolves' , 'resolved' ] ; export function getReferencedIssue ( owner , repo , prBody ) { var regex = new RegExp ( `(${ ISSUE_CLOSING_KEYWORDS . join ( '|' ) }) #\\d{1,}` , 'i' ) ; var matched = prBody . match ( regex ) || [ ] ; if ( matched . length > 0 ) { const issue = matched [ 0 ] . match ( /#\d{1,}/i ) || [ ] ; if ( issue . length > 0 ) { const issueNumber = issue [ 0 ] . replace ( '#' , '' ) ; return Number ( issueNumber ) ; } } regex = new RegExp ( `(${ ISSUE_CLOSING_KEYWORDS . join ( '|' ) }) https:\\/\\/github.com\\/${ owner }\\/${ repo }\\/issues\\/\\d{1,}` , 'i' ) ; matched = prBody . match ( regex ) || [ ] ; if ( matched . length > 0 ) { const issue = matched [ 0 ] . split ( '/' ) . pop ( ) ; if ( issue ) { return Number ( issue ) ; } } return undefined ; }