Merge pull request #15518 from developStorm/patch-1

fix: broken url when not using optional :page parameter
This commit is contained in:
DIYgod 2024-05-08 12:00:52 +01:00 committed by GitHub
commit 6b3e4444c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 1 deletions

View File

@ -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);