From 8c679563d85769f6e3956eb7b18d6cf4d2781c4f Mon Sep 17 00:00:00 2001 From: RealDiligent Date: Thu, 23 Jul 2026 00:34:14 +0800 Subject: [PATCH] fix(extension): remove stranded matchPullRequestTarget duplicate from content.js (#8023) --- apps/loopover-extension/content.js | 7 ------- test/unit/extension-content.test.ts | 20 ++++++++------------ 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/apps/loopover-extension/content.js b/apps/loopover-extension/content.js index 29f94aed4a..f5e58b5306 100644 --- a/apps/loopover-extension/content.js +++ b/apps/loopover-extension/content.js @@ -13,12 +13,6 @@ function matchGitHubPageTarget(pathname) { return { kind: "pull_request", owner, repo, pullNumber: Number(number) }; } -function matchPullRequestTarget(pathname) { - const target = matchGitHubPageTarget(pathname); - if (!target) return null; - return { owner: target.owner, repo: target.repo, pullNumber: target.pullNumber }; -} - function mountOverlay(target) { if (document.querySelector("[data-loopover-pr-context]")) return; const container = document.createElement("aside"); @@ -192,7 +186,6 @@ function renderActions(body, actions) { if (globalThis.__LOOPOVER_EXTENSION_TEST__) { globalThis.__loopoverContentInternals = { matchGitHubPageTarget, - matchPullRequestTarget, createOverlayLoader, renderPullContext, renderSection, diff --git a/test/unit/extension-content.test.ts b/test/unit/extension-content.test.ts index e8b9957503..7f3042b94b 100644 --- a/test/unit/extension-content.test.ts +++ b/test/unit/extension-content.test.ts @@ -22,21 +22,18 @@ describe("extension content script", () => { repo: "loopover", pullNumber: 146, }); - // Issue pages are out of scope — no kind:"issue" classification, and no match. - expect(internals.matchGitHubPageTarget("/JSONbored/loopover/issues/145")).toBeNull(); - expect(internals.matchGitHubPageTarget("/JSONbored/loopover/pulls")).toBeNull(); - expect(internals.matchPullRequestTarget("/JSONbored/loopover/pull/146")).toEqual({ - owner: "JSONbored", - repo: "loopover", - pullNumber: 146, - }); - expect(internals.matchPullRequestTarget("/JSONbored/loopover/pull/146/files")).toEqual({ + // Sub-pages of a pull request (e.g. /files) still match — kept from the retired + // matchPullRequestTarget duplicate's coverage (#8023) so the route regex keeps this pinned. + expect(internals.matchGitHubPageTarget("/JSONbored/loopover/pull/146/files")).toEqual({ + kind: "pull_request", owner: "JSONbored", repo: "loopover", pullNumber: 146, }); - expect(internals.matchPullRequestTarget("/JSONbored/loopover/issues/146")).toBeNull(); - expect(internals.matchPullRequestTarget("/JSONbored/loopover")).toBeNull(); + // Issue pages are out of scope — no kind:"issue" classification, and no match. + expect(internals.matchGitHubPageTarget("/JSONbored/loopover/issues/145")).toBeNull(); + expect(internals.matchGitHubPageTarget("/JSONbored/loopover/pulls")).toBeNull(); + expect(internals.matchGitHubPageTarget("/JSONbored/loopover")).toBeNull(); }); it("renders private pull-context sections and escapes API text", () => { @@ -134,7 +131,6 @@ function loadContentInternals(overrides: Record = {}) { matchGitHubPageTarget: ( pathname: string, ) => { kind: "pull_request"; owner: string; repo: string; pullNumber: number } | null; - matchPullRequestTarget: (pathname: string) => { owner: string; repo: string; pullNumber: number } | null; createOverlayLoader: (container: { querySelector: (selector: string) => unknown }, target: unknown) => () => Promise; renderPullContext: (payload: unknown) => string; };