Skip to content

Commit 46bdd94

Browse files
fix: handle missing SUMMARY without crashing transform
Normalize missing event titles to an empty string before the view transform runs, so event.title.search() no longer throws when an ICS entry has no SUMMARY. Add a regression test for events without a title. Ref #465.
1 parent 56fa86e commit 46bdd94

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

node_helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ module.exports = NodeHelper.create({
143143
ev.calendarId = calendar.uid;
144144
ev.location = item.location;
145145
ev.description = item.description;
146-
ev.title = item.summary;
146+
ev.title = item.summary || "";
147147
ev.isRecurring = item.isRecurring;
148148
ev.attendees = item.attendees || [];
149149
ev.categories = item.categories || [];

test/node-helper-parser.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ const ICS_TWO_EVENTS = joinIcs(
5454
"END:VCALENDAR"
5555
);
5656

57+
const ICS_EVENT_WITHOUT_SUMMARY = joinIcs(
58+
"BEGIN:VCALENDAR",
59+
"VERSION:2.0",
60+
"BEGIN:VEVENT",
61+
"UID:evt-no-summary",
62+
`DTSTART:${dtDay}T140000Z`,
63+
`DTEND:${dtDay}T150000Z`,
64+
"END:VEVENT",
65+
"END:VCALENDAR"
66+
);
67+
5768
const makeCalendar = (overrides = {}) => ({
5869
uid: 0,
5970
name: "test-cal",
@@ -148,4 +159,14 @@ describe("node_helper – parser() event filtering", () => {
148159
const [, events] = sendSocketNotification.mock.calls[0].arguments;
149160
assert.equal(events.length, 1);
150161
});
162+
163+
it("normalizes missing event summaries to an empty title", () => {
164+
const {ctx, sendSocketNotification} = makeCtx();
165+
166+
ctx.parser(makeCalendar(), ICS_EVENT_WITHOUT_SUMMARY);
167+
168+
const [, events] = sendSocketNotification.mock.calls[0].arguments;
169+
assert.equal(events.length, 1);
170+
assert.equal(events[0].title, "");
171+
});
151172
});

0 commit comments

Comments
 (0)