diff --git a/lib/routes/github/eventapi.ts b/lib/routes/github/eventapi.ts
index 3b8e7ecd0e..20a0dec6a5 100644
--- a/lib/routes/github/eventapi.ts
+++ b/lib/routes/github/eventapi.ts
@@ -34,7 +34,7 @@ function formatEventItem(event: any) {
description = `Pushed ${commitCount}to ${branch} in ${repo.name}`;
if (payload.commits) {
- link = payload.commits.at(-1).url.replace('api.github.com/repos/', 'github.com/').replace('/commits/', '/commit/');
+ link = payload.commits.at(-1).url.replace(/https:\/\/api\.github\.com\/repos\/([^/]+)\/([^/]+)\/commits\/(\d+)/, 'https://github.com/$1/$2/commit/$3');
description += `
Latest commit: ${payload.commits.at(-1).message}`;
} else {
link = `https://github.com/${repo.name}/commit/${payload.head}`;
@@ -43,8 +43,13 @@ function formatEventItem(event: any) {
}
case 'PullRequestEvent':
title = `${actor.login} ${payload.action} a pull request in ${repo.name}`;
- description = `PR: ${payload.pull_request?.url || 'Unknown'}`;
- link = payload.pull_request?.url || `https://github.com/${repo.name}`;
+ if (payload.pull_request) {
+ link = payload.pull_request.url.replace(/https:\/\/api\.github\.com\/repos\/([^/]+)\/([^/]+)\/pulls\/(\d+)/, 'https://github.com/$1/$2/pull/$3');
+ description = `PR: ${link}`;
+ } else {
+ link = `https://github.com/${repo.name}`;
+ description = `PR: Unknown`;
+ }
break;
case 'PullRequestReviewCommentEvent':
title = `${actor.login} commented on a pull request review in ${repo.name}`;