feat(calendars): make merged calendars with .ics suffix return same calendar as the merged calendar without the .ics suffix
This commit is contained in:
parent
30622c611a
commit
55826b8dde
3 changed files with 9 additions and 3 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
||||||
node_modules/
|
node_modules/
|
||||||
test/calendar/
|
test/calendar/
|
||||||
calendar/
|
calendar/
|
||||||
logs/
|
logs/
|
||||||
|
.qodo
|
||||||
|
|
Binary file not shown.
|
@ -57,7 +57,12 @@ async function refreshCalendarData(calendarName) {
|
||||||
|
|
||||||
// Serve the merged calendar file and refresh if older than an hour
|
// Serve the merged calendar file and refresh if older than an hour
|
||||||
router.get('/calendar/:name', async (req, res) => {
|
router.get('/calendar/:name', async (req, res) => {
|
||||||
const calendarName = req.params.name;
|
// Extract the calendar name and remove .ics extension if present
|
||||||
|
let calendarName = req.params.name;
|
||||||
|
if (calendarName.endsWith('.ics')) {
|
||||||
|
calendarName = calendarName.slice(0, -4);
|
||||||
|
}
|
||||||
|
|
||||||
const icsFilePath = path.join(MERGED_CALENDARS_DIR, `${calendarName}.ics`);
|
const icsFilePath = path.join(MERGED_CALENDARS_DIR, `${calendarName}.ics`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -82,4 +87,4 @@ router.get('/calendar/:name', async (req, res) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default router;
|
export default router;
|
Loading…
Add table
Reference in a new issue