Skip to content

Commit

Permalink
feat(route): Rewrite the API URL to original URL (#14617)
Browse files Browse the repository at this point in the history
* feat(route): Rewrite the API URL to original URL

* Update notifications.js

* camelCase
  • Loading branch information
psychosispy authored Mar 2, 2024
1 parent 94cb794 commit 5928c5d
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/routes/github/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@ export default async (ctx) => {
});
const notifications = response.data;

const items = notifications.map((item) => ({
title: item.subject.title,
description: item.subject.title,
pubDate: parseDate(item.updated_at), // item.updated_at follows ISO 8601.
guid: item.id,
link: item.subject.url,
}));
const items = notifications.map((item) => {
let originUrl = item.subject.url ? item.subject.url.replace('https://api.github.com/repos/', 'https://github.com/') : 'https://github.com/notifications';
if (originUrl.includes('/releases/')) {
originUrl = originUrl.replace(/\/releases\/\d+$/, '/releases');
}
return {
title: item.subject.title,
description: item.subject.title,
pubDate: parseDate(item.updated_at), // item.updated_at follows ISO 8601.
guid: item.id,
link: originUrl,
};
});

ctx.set('data', {
title: 'Github Notifications',
Expand Down

0 comments on commit 5928c5d

Please sign in to comment.