Skip to content

Commit 87766eb

Browse files
fix(extension): drop dead issue-page content-script match (#7487)
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 4ae3854 commit 87766eb

3 files changed

Lines changed: 20 additions & 15 deletions

File tree

apps/loopover-extension/content.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
const target = matchGitHubPageTarget(location.pathname);
22

3-
if (target?.kind === "pull_request") {
3+
if (target) {
44
mountOverlay(target);
55
}
66

7+
// #7462: pull-request pages only — issue classification was dead (manifest matched issues/*
8+
// but nothing consumed kind:"issue", and there is no issue-context backend route).
79
function matchGitHubPageTarget(pathname) {
8-
const match = String(pathname ?? "").match(/^\/([^/]+)\/([^/]+)\/(pull|issues)\/(\d+)(?:\/|$)/);
10+
const match = String(pathname ?? "").match(/^\/([^/]+)\/([^/]+)\/pull\/(\d+)(?:\/|$)/);
911
if (!match) return null;
10-
const [, owner, repo, surface, number] = match;
11-
if (surface === "pull") return { kind: "pull_request", owner, repo, pullNumber: Number(number) };
12-
return { kind: "issue", owner, repo, issueNumber: Number(number) };
12+
const [, owner, repo, number] = match;
13+
return { kind: "pull_request", owner, repo, pullNumber: Number(number) };
1314
}
1415

1516
function matchPullRequestTarget(pathname) {
1617
const target = matchGitHubPageTarget(pathname);
17-
if (target?.kind !== "pull_request") return null;
18+
if (!target) return null;
1819
return { owner: target.owner, repo: target.repo, pullNumber: target.pullNumber };
1920
}
2021

apps/loopover-extension/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"content_scripts": [
1313
{
14-
"matches": ["https://github.com/*/*/pull/*", "https://github.com/*/*/issues/*"],
14+
"matches": ["https://github.com/*/*/pull/*"],
1515
"js": ["content.js"],
1616
"css": ["styles.css"],
1717
"run_at": "document_idle"

test/unit/extension-content.test.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@ import { Script, createContext } from "node:vm";
33
import { describe, expect, it, vi } from "vitest";
44

55
const contentScript = readFileSync("apps/loopover-extension/content.js", "utf8");
6+
const manifest = JSON.parse(readFileSync("apps/loopover-extension/manifest.json", "utf8")) as {
7+
content_scripts: Array<{ matches: string[] }>;
8+
};
69

710
describe("extension content script", () => {
8-
it("detects GitHub pull request and issue routes while only mounting pull overlays", () => {
11+
it("declares content-script matches for pull pages only (#7462)", () => {
12+
expect(manifest.content_scripts[0]?.matches).toEqual(["https://github.com/*/*/pull/*"]);
13+
expect(manifest.content_scripts[0]?.matches.join("\n")).not.toContain("issues");
14+
});
15+
16+
it("detects GitHub pull request routes and treats issue pages as out of scope", () => {
917
const internals = loadContentInternals();
1018

1119
expect(internals.matchGitHubPageTarget("/JSONbored/loopover/pull/146")).toEqual({
@@ -14,12 +22,8 @@ describe("extension content script", () => {
1422
repo: "loopover",
1523
pullNumber: 146,
1624
});
17-
expect(internals.matchGitHubPageTarget("/JSONbored/loopover/issues/145")).toEqual({
18-
kind: "issue",
19-
owner: "JSONbored",
20-
repo: "loopover",
21-
issueNumber: 145,
22-
});
25+
// Issue pages are out of scope — no kind:"issue" classification, and no match.
26+
expect(internals.matchGitHubPageTarget("/JSONbored/loopover/issues/145")).toBeNull();
2327
expect(internals.matchGitHubPageTarget("/JSONbored/loopover/pulls")).toBeNull();
2428
expect(internals.matchPullRequestTarget("/JSONbored/loopover/pull/146")).toEqual({
2529
owner: "JSONbored",
@@ -91,7 +95,7 @@ function loadContentInternals() {
9195
return vmContext.__loopoverContentInternals as {
9296
matchGitHubPageTarget: (
9397
pathname: string,
94-
) => { kind: "pull_request"; owner: string; repo: string; pullNumber: number } | { kind: "issue"; owner: string; repo: string; issueNumber: number } | null;
98+
) => { kind: "pull_request"; owner: string; repo: string; pullNumber: number } | null;
9599
matchPullRequestTarget: (pathname: string) => { owner: string; repo: string; pullNumber: number } | null;
96100
renderPullContext: (payload: unknown) => string;
97101
};

0 commit comments

Comments
 (0)