Skip to content

Commit 5928c5d

Browse files
authored
feat(route): Rewrite the API URL to original URL (#14617)
* feat(route): Rewrite the API URL to original URL * Update notifications.js * camelCase
1 parent 94cb794 commit 5928c5d

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

lib/routes/github/notifications.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@ export default async (ctx) => {
1919
});
2020
const notifications = response.data;
2121

22-
const items = notifications.map((item) => ({
23-
title: item.subject.title,
24-
description: item.subject.title,
25-
pubDate: parseDate(item.updated_at), // item.updated_at follows ISO 8601.
26-
guid: item.id,
27-
link: item.subject.url,
28-
}));
22+
const items = notifications.map((item) => {
23+
let originUrl = item.subject.url ? item.subject.url.replace('https://api.github.com/repos/', 'https://github.com/') : 'https://github.com/notifications';
24+
if (originUrl.includes('/releases/')) {
25+
originUrl = originUrl.replace(/\/releases\/\d+$/, '/releases');
26+
}
27+
return {
28+
title: item.subject.title,
29+
description: item.subject.title,
30+
pubDate: parseDate(item.updated_at), // item.updated_at follows ISO 8601.
31+
guid: item.id,
32+
link: originUrl,
33+
};
34+
});
2935

3036
ctx.set('data', {
3137
title: 'Github Notifications',

0 commit comments

Comments
 (0)