mirror of
https://github.com/fabrice404/olympics-calendar.git
synced 2026-02-10 16:59:57 +00:00
fix ical validation errors
This commit is contained in:
22
src/ics.js
22
src/ics.js
@ -19,7 +19,27 @@ const generateICS = (title, key, events) => {
|
||||
lines.push(
|
||||
...Object.entries(event)
|
||||
.filter(([key]) => !key.startsWith("_"))
|
||||
.map(([key, value]) => `${key}:${value}`),
|
||||
.map(([key, value]) => {
|
||||
let result = `${key}:${value}`;
|
||||
if (result.length > 75) {
|
||||
if (key === "DESCRIPTION") {
|
||||
const lines = [];
|
||||
while (result.length > 75) {
|
||||
let index = 75;
|
||||
while (result[index] !== " " && index > 0) {
|
||||
index--;
|
||||
}
|
||||
lines.push(result.slice(0, index));
|
||||
result = " " + result.slice(index);
|
||||
}
|
||||
lines.push(result);
|
||||
return lines.join("\r\n").trim();
|
||||
}
|
||||
return `${key}:${value}`.slice(0, 75);
|
||||
}
|
||||
return `${key}:${value}`;
|
||||
|
||||
}),
|
||||
);
|
||||
lines.push("END:VEVENT");
|
||||
});
|
||||
|
||||
@ -135,9 +135,9 @@ const extractSportCalendar = async (sportKey) => {
|
||||
// more than two, we put them in the description
|
||||
competitors.forEach((competitor) => {
|
||||
if (competitor.name !== getNOCName(competitor.noc)) {
|
||||
event.DESCRIPTION += `\r\n${getNOCFlag(competitor.noc)} ${competitor.name}`;
|
||||
event.DESCRIPTION += `\\n${getNOCFlag(competitor.noc)} ${competitor.name}`;
|
||||
} else {
|
||||
event.DESCRIPTION += `\r\n${getNOCFlag(competitor.noc)} ${competitor.noc}`;
|
||||
event.DESCRIPTION += `\\n${getNOCFlag(competitor.noc)} ${competitor.noc}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user