Merge pull request #15518 from developStorm/patch-1
fix: broken url when not using optional :page parameter
This commit is contained in:
commit
6b3e4444c7
|
|
@ -32,7 +32,15 @@ export const route: Route = {
|
|||
async function handler(ctx) {
|
||||
const { user, repo, page } = ctx.req.param();
|
||||
|
||||
const url = `${baseUrl}/${user}/${repo}/wiki${page ? `/${page}` : ''}/_history`;
|
||||
let url = `${baseUrl}/${user}/${repo}/wiki${page ? `/${page}` : ''}/_history`;
|
||||
|
||||
// Fetch page slug. History fetched with no page specified has no <a> tag for commit.
|
||||
if (!page) {
|
||||
const { data } = await got(`${baseUrl}/${user}/${repo}/wiki`);
|
||||
const $ = load(data);
|
||||
|
||||
url = `${baseUrl}${$('a[href$=_history]').attr('href')}`;
|
||||
}
|
||||
|
||||
const { data } = await got(url);
|
||||
const $ = load(data);
|
||||
|
|
|
|||
Loading…
Reference in New Issue