fix(route/github): Fix URL link error in events (#20386)

* fix(route/github): Fix url of PR event not links to HTML page

* fix(route/github): Fix repo info be replaced in push event

* style: auto format

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
mslxl
2025-10-28 20:14:44 +08:00
committed by GitHub
co-authored by github-actions[bot]
parent 961bb9ce0c
commit 49a58764fa
+8 -3
View File
@@ -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 += `<br><strong>Latest commit:</strong> ${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}`;