From cbf76386f973396d32ae7a83808a7dfa38213506 Mon Sep 17 00:00:00 2001 From: ramimbo <160272258+ramimbo@users.noreply.github.com> Date: Fri, 22 May 2026 18:58:07 +0000 Subject: [PATCH] Fix recent actions PR links --- github-sortout.user.js | 5 ++++- tests/github-sortout.spec.js | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/github-sortout.user.js b/github-sortout.user.js index f2dd314..743909b 100644 --- a/github-sortout.user.js +++ b/github-sortout.user.js @@ -569,10 +569,13 @@ const RecentActions = (() => { const createdAt = event.created_at || ''; if (event.type === 'PullRequestEvent' && payload.pull_request) { + const url = payload.pull_request.html_url || + (repo && payload.number ? `https://github.com/${repo}/pull/${payload.number}` : ''); + return { kind: 'PR', title: payload.pull_request.title || 'Pull request', - url: payload.pull_request.html_url, + url, repo, createdAt, }; diff --git a/tests/github-sortout.spec.js b/tests/github-sortout.spec.js index 7c5d848..52b0c50 100644 --- a/tests/github-sortout.spec.js +++ b/tests/github-sortout.spec.js @@ -318,6 +318,33 @@ test('renders public GitHub events in a full-screen overlay without executing HT await expect(page.evaluate(() => window.__sortoutXss)).resolves.toBeUndefined(); }); +test('links pull request events when GitHub omits html_url', async ({ page }) => { + await openFixture(page, 'https://github.com/', '
Home
'); + await page.route('https://api.github.com/users/octocat/events/public?per_page=100', (route) => route.fulfill({ + contentType: 'application/json', + body: JSON.stringify([ + { + type: 'PullRequestEvent', + created_at: '2026-05-20T12:00:00.000Z', + repo: { name: 'owner/repo' }, + payload: { + action: 'opened', + number: 123, + pull_request: { + title: 'PR without html_url', + url: 'https://api.github.com/repos/owner/repo/pulls/123', + }, + }, + }, + ]), + })); + + await installScript(page); + await page.locator('#ghs-trigger').click(); + + await expect(page.locator('#ghs-actions-list a')).toHaveAttribute('href', 'https://github.com/owner/repo/pull/123'); +}); + test('shows the latest 20 public actions by default with count options', async ({ page }) => { const events = Array.from({ length: 25 }, (_, index) => ({ type: 'PullRequestEvent',