From 379a79617bd43054c759fc341ed17ef51ab5463c Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Tue, 19 Nov 2024 19:06:22 +0300 Subject: [PATCH] fix(lineendings): normalize calendar line endings to CRLF --- src/calendarUtil.js | 2 +- test/calendar.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calendarUtil.js b/src/calendarUtil.js index 4d6df81..0450d83 100644 --- a/src/calendarUtil.js +++ b/src/calendarUtil.js @@ -151,7 +151,7 @@ export function addEventsToCalendar(calendarComponent, results, overrideFlag = f // Save calendar data to file export function saveCalendarFile(filename, content) { - const normalizedContent = content.replace(/\r\n/g, '\n').trimEnd(); // Normalize to LF + const normalizedContent = content.replace(/\r?\n/g, '\r\n').trimEnd(); // Normalize to CRLF const filePath = path.join(MERGED_CALENDARS_DIR, filename); // console.log(`Saving calendar data to file: ${filePath}`); fs.writeFileSync(filePath, normalizedContent); diff --git a/test/calendar.test.js b/test/calendar.test.js index 761e15e..4619b89 100644 --- a/test/calendar.test.js +++ b/test/calendar.test.js @@ -12,7 +12,7 @@ process.chdir(__dirname) // console.log(process.cwd()); const app = require('../src/server').default; -const normalizeLineEndings = (str) => str.replace(/\r\n/g, '\n').trimEnd(); +const normalizeLineEndings = (str) => str.replace(/\r\n/g, '\r\n').trimEnd(); // Normalize to CRLF describe('Calendar Merging API', () => { beforeAll(async () => {