Skip to content
Closed
Show file tree
Hide file tree
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
7 changes: 0 additions & 7 deletions apps/loopover-extension/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -192,7 +186,6 @@ function renderActions(body, actions) {
if (globalThis.__LOOPOVER_EXTENSION_TEST__) {
globalThis.__loopoverContentInternals = {
matchGitHubPageTarget,
matchPullRequestTarget,
createOverlayLoader,
renderPullContext,
renderSection,
Expand Down
20 changes: 8 additions & 12 deletions test/unit/extension-content.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down Expand Up @@ -134,7 +131,6 @@ function loadContentInternals(overrides: Record<string, unknown> = {}) {
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<void>;
renderPullContext: (payload: unknown) => string;
};
Expand Down
Loading