mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
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:
co-authored by
github-actions[bot]
parent
961bb9ce0c
commit
49a58764fa
@@ -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}`;
|
||||
|
||||
Reference in New Issue
Block a user