diff --git a/index.js b/index.js
index 39c854c..e2cd905 100644
--- a/index.js
+++ b/index.js
@@ -1,11 +1,11 @@
'use strict'
-const PR_RE = /\/nodejs\/([^\/]+)\/pull\/([^\/]+)\/?$/
+const PR_RE = /^\/nodejs\/([^\/]+)\/pull\/([^\/]+)\/?$/
const b = chrome.extension.getBackgroundPage()
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (changeInfo.url === undefined) return
- if (PR_RE.test(changeInfo.url)) {
+ if (PR_RE.test(new URL(changeInfo.url).pathname)) {
chrome.browserAction.enable()
chrome.browserAction.setIcon({
path: 'icon_good.png'
diff --git a/review.js b/review.js
index 3784312..eee5475 100644
--- a/review.js
+++ b/review.js
@@ -6,7 +6,7 @@
, REJECTED: 'REJECTED'
}
- const PR_RE = /\/nodejs\/([^\/]+)\/pull\/([^\/]+)\/?$/
+ const PR_RE = /^\/nodejs\/([^\/]+)\/pull\/([^\/]+)\/?$/
const { prUrl, repo } = getPR()
if (!prUrl) {
@@ -38,6 +38,7 @@
const status = this.reviewers.get(login)
if (status === STATUS.APPROVED) return
this.rejections -= 1
+ this.approvals += 1
this.reviewers.set(login, STATUS.APPROVED)
}
@@ -50,6 +51,7 @@
const status = this.reviewers.get(login)
if (status === STATUS.REJECTED) return
this.approvals -= 1
+ this.rejections += 1
this.reviewers.set(login, STATUS.REJECTED)
}
}
@@ -120,35 +122,13 @@
}
}
- function getFixesUrl() {
- const op = document.querySelector('.discussion-timeline .comment-body')
- const text = op.innerText
-
- var fixes = text.match(FIXES_RE)
- if (fixes) {
- const tmp = fixes[1]
- if (tmp[0] === '#') {
- // This is a reference to an issue in the current repository.
- // Generate the full url
- return `https://github.com/${repo}/issues/${tmp.slice(1)}`
- } else {
- return `https://github.com/${tmp}`
- }
- }
-
- return null
- }
-
function getFixesUrlsFromArray(ar) {
return ar.reduce((set, item) => {
const m = item.match(FIX_RE)
if (!m) return set
const fix = m[1]
- if (fix[0] === '#') {
- set.push(`https://github.com/${repo}/issues/${fix.slice(1)}`)
- } else {
- set.push(`https://github.com/${fix}`)
- }
+ const url = fix.replace(/^#/, `${repo}#`).replace('#', '/issues/')
+ set.push(`https://github.com/${url}`)
return set
}, [])
}
@@ -211,7 +191,7 @@
function formatMeta(meta, collabs) {
const revs = []
for (const name of meta.reviewers.keys()) {
- const c = collabs[name]
+ const c = collabs.get(name)
if (!c) {
console.error('skipping unknown reviewer', name)
continue
@@ -238,8 +218,7 @@
return `
${result.join('\n')}
- ${revs.join('
')}
-
+ ${revs.join('
')}