Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions browser-extension/src/lib/enhancers/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import type { CommentEnhancer, CommentSpot } from '../enhancer'

const GITHUB_SPOT_TYPES = [
'GH_PR_ADD_COMMENT',
'GH_ISSUE_ADD_COMMENT',
/* TODO
'GH_ISSUE_NEW',
'GH_PR_NEW',
'GH_ISSUE_ADD_COMMENT',
'GH_ISSUE_EDIT_COMMENT',
'GH_PR_EDIT_COMMENT',
'GH_PR_CODE_COMMENT',
Expand Down Expand Up @@ -38,10 +38,11 @@ export class GitHubAddCommentEnhancer implements CommentEnhancer<GitHubAddCommen
// Parse GitHub URL structure: /owner/repo/issues/123 or /owner/repo/pull/456
logger.debug(`${this.constructor.name} examing url`, window.location.pathname)

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

Expand All @@ -51,7 +52,7 @@ export class GitHubAddCommentEnhancer implements CommentEnhancer<GitHubAddCommen
domain: 'github.com',
number,
slug,
type: 'GH_PR_ADD_COMMENT',
type,
unique_key,
}
return [this.createOvertypeFor(textarea), spot]
Expand Down