diff --git a/docs/en/programming.md b/docs/en/programming.md
index 08936ea057..e703c21f51 100644
--- a/docs/en/programming.md
+++ b/docs/en/programming.md
@@ -141,7 +141,7 @@ For instance, the `/github/topics/framework/l=php&o=desc&s=stars` route will gen
### Repo Pull Requests
-
+
### User Followers
diff --git a/docs/programming.md b/docs/programming.md
index eeedd748e5..8f919efc1d 100644
--- a/docs/programming.md
+++ b/docs/programming.md
@@ -219,7 +219,7 @@ GitHub 官方也提供了一些 RSS:
### 仓库 Pull Requests
-
+
### 用户 Followers
diff --git a/lib/v2/github/maintainer.js b/lib/v2/github/maintainer.js
index 87e1db702e..a286a5e2bc 100644
--- a/lib/v2/github/maintainer.js
+++ b/lib/v2/github/maintainer.js
@@ -4,7 +4,7 @@ module.exports = {
'/contributors/:user/:repo/:order?/:anon?': ['zoenglinghou'],
'/file/:user/:repo/:branch/:filepath+': ['zengxs'],
'/issue/:user/:repo/:state?/:labels?': ['HenryQW', 'AndreyMZ'],
- '/pull/:user/:repo': ['hashman'],
+ '/pull/:user/:repo/:state?': ['hashman', 'TonyRL'],
'/repos/:user': ['DIYgod'],
'/search/:query/:sort?/:order?': ['LogicJake'],
'/starred_repos/:user': ['LanceZhu'],
diff --git a/lib/v2/github/pulls.js b/lib/v2/github/pulls.js
index 036c38f6af..ceac91e6a5 100644
--- a/lib/v2/github/pulls.js
+++ b/lib/v2/github/pulls.js
@@ -5,13 +5,14 @@ const md = require('markdown-it')({
linkify: true,
});
const queryString = require('query-string');
+const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const user = ctx.params.user;
const repo = ctx.params.repo;
+ const state = ctx.params.state ?? 'open';
const host = `https://github.com/${user}/${repo}/pulls`;
- const link = `https://github.com/${user}/${repo}/pull`;
const url = `https://api.github.com/repos/${user}/${repo}/pulls`;
const headers = {};
@@ -22,7 +23,10 @@ module.exports = async (ctx) => {
method: 'get',
url,
searchParams: queryString.stringify({
+ state,
sort: 'created',
+ direction: 'desc',
+ per_page: ctx.query.limit ? (parseInt(ctx.query.limit) <= 100 ? parseInt(ctx.query.limit) : 100) : 100,
}),
headers,
});
@@ -36,8 +40,8 @@ module.exports = async (ctx) => {
title: item.title,
author: item.user.login,
description: item.body ? md.render(item.body) : 'No description',
- pubDate: new Date(item.created_at).toUTCString(),
- link: `${link}/${item.number}`,
+ pubDate: parseDate(item.created_at),
+ link: item.html_url,
})),
};
};
diff --git a/lib/v2/github/router.js b/lib/v2/github/router.js
index 1dda4be8c3..54b517de88 100644
--- a/lib/v2/github/router.js
+++ b/lib/v2/github/router.js
@@ -4,7 +4,7 @@ module.exports = function (router) {
router.get('/contributors/:user/:repo/:order?/:anon?', require('./contributors'));
router.get('/file/:user/:repo/:branch/:filepath+', require('./file'));
router.get('/issue/:user/:repo/:state?/:labels?', require('./issue'));
- router.get('/pull/:user/:repo', require('./pulls'));
+ router.get('/pull/:user/:repo/:state?', require('./pulls'));
router.get('/repos/:user', require('./repos'));
router.get('/search/:query/:sort?/:order?', require('./search'));
router.get('/starred_repos/:user', require('./starred_repos'));