diff --git a/submit.go b/submit.go index 52825ac..4fc8ceb 100644 --- a/submit.go +++ b/submit.go @@ -120,11 +120,13 @@ type submitResponse struct { ReportURL string `json:"report_url,omitempty"` } -// regex to catch and substitute ambiguous issue references with explicit ones to the actual repo they are in -var ambiguousIssueRegex = regexp.MustCompile(`(^|[([{\s])(#\d+)([^\w]|$)`) +// regex to match and substitute ambiguous issue references in the rageshake body text +// matches a hash followed by digits optionally surrounded by whitespace or some punctuation +// also matches if the input starts with digits where the hash becomes optional +var ambiguousIssueRegex = regexp.MustCompile(`(^|[([{\s])(?:^|#)(\d+)([^\w]|$)`) func replaceAmbiguousIssueReferences(ownerRepo, text string) string { - t := ambiguousIssueRegex.ReplaceAllString(text, fmt.Sprintf("${1}%s$2$3", ownerRepo)) + t := ambiguousIssueRegex.ReplaceAllString(text, fmt.Sprintf("${1}%s#$2$3", ownerRepo)) return t } diff --git a/submit_test.go b/submit_test.go index 499d1b8..06f9ee0 100644 --- a/submit_test.go +++ b/submit_test.go @@ -492,6 +492,8 @@ func TestAutocompleteIssueReferences(t *testing.T) { "test (#123) bar": "test (owner/repo#123) bar", // brackets "Start #123. Now": "Start owner/repo#123. Now", // followed by punctuation "#123foo": "#123foo", // ignore + "foo/#123": "foo/#123", // ignore + "123": "owner/repo#123", // special case for entire body being a number } for text, expect := range tests {