Skip to content

Commit b28f23c

Browse files
committed
Fix the regex so it works on issues too (breaks the issues CSS)
1 parent a7f4ea4 commit b28f23c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

browser-extension/src/lib/enhancers/github.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import type { CommentEnhancer, CommentSpot } from '../enhancer'
55

66
const GITHUB_SPOT_TYPES = [
77
'GH_PR_ADD_COMMENT',
8+
'GH_ISSUE_ADD_COMMENT',
89
/* TODO
910
'GH_ISSUE_NEW',
1011
'GH_PR_NEW',
11-
'GH_ISSUE_ADD_COMMENT',
1212
'GH_ISSUE_EDIT_COMMENT',
1313
'GH_PR_EDIT_COMMENT',
1414
'GH_PR_CODE_COMMENT',
@@ -38,10 +38,11 @@ export class GitHubAddCommentEnhancer implements CommentEnhancer<GitHubAddCommen
3838
// Parse GitHub URL structure: /owner/repo/issues/123 or /owner/repo/pull/456
3939
logger.debug(`${this.constructor.name} examing url`, window.location.pathname)
4040

41-
const match = window.location.pathname.match(/^\/([^/]+)\/([^/]+)(?:\/pull\/(\d+))/)
41+
const match = window.location.pathname.match(/^\/([^/]+)\/([^/]+)(?:\/(pull|issues)\/(\d+))/)
4242
logger.debug(`${this.constructor.name} found match`, window.location.pathname)
4343
if (!match) return null
44-
const [, owner, repo, numberStr] = match
44+
const [, owner, repo, issuesOrPull, numberStr] = match
45+
const type = issuesOrPull === 'issues' ? 'GH_ISSUE_ADD_COMMENT' : 'GH_PR_ADD_COMMENT'
4546
const slug = `${owner}/${repo}`
4647
const number = parseInt(numberStr!, 10)
4748

@@ -51,7 +52,7 @@ export class GitHubAddCommentEnhancer implements CommentEnhancer<GitHubAddCommen
5152
domain: 'github.com',
5253
number,
5354
slug,
54-
type: 'GH_PR_ADD_COMMENT',
55+
type,
5556
unique_key,
5657
}
5758
return [this.createOvertypeFor(textarea), spot]

0 commit comments

Comments
 (0)