Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix(calendar): safely handle whitespace hangout_link and nullish candidates in meeting join URL helpers (#1579) (#1580)

Henry Suc3f6213aaa23
diff --git a/src/helpers/meetingJoinUrl.js b/src/helpers/meetingJoinUrl.js
index ac27bca5b..82881536a 100644
--- a/src/helpers/meetingJoinUrl.js
+++ b/src/helpers/meetingJoinUrl.js
@@ -3,11 +3,15 @@ const MEETING_URL_PATTERN =
export function getMeetingJoinUrl(event) {
if (!event) return null;
- if (event.hangout_link) return event.hangout_link;
+ const hangoutLink = event.hangout_link?.trim();
+ if (hangoutLink) return hangoutLink;
if (!event.conference_data) return null;
try {
const data = JSON.parse(event.conference_data);
- return data?.entryPoints?.find((ep) => ep.entryPointType === "video")?.uri ?? null;
+ const uri = data?.entryPoints
+ ?.find((ep) => ep.entryPointType === "video" && ep.uri?.trim())
+ ?.uri?.trim();
+ return uri || null;
} catch {
return null;
}
@@ -16,6 +20,7 @@ export function getMeetingJoinUrl(event) {
// Finds a meeting link in loose text (EventKit has no structured conference
// data — Zoom/Meet/Teams/Webex links live in url, location, or notes).
export function extractMeetingUrl(candidates) {
+ if (!Array.isArray(candidates)) return null;
for (const candidate of candidates) {
const match = candidate?.match?.(MEETING_URL_PATTERN);
if (match) return match[0].replace(/[),.;:!?]+$/, "");
diff --git a/test/helpers/meetingJoinUrl.test.js b/test/helpers/meetingJoinUrl.test.js
index 732a58799..13d922114 100644
--- a/test/helpers/meetingJoinUrl.test.js
+++ b/test/helpers/meetingJoinUrl.test.js
@@ -92,6 +92,26 @@ test("extractMeetingUrl returns the first matching candidate", async () => {
test("extractMeetingUrl returns null when nothing matches", async () => {
const { extractMeetingUrl } = await load();
assert.equal(extractMeetingUrl([]), null);
+ assert.equal(extractMeetingUrl(null), null);
+ assert.equal(extractMeetingUrl(undefined), null);
+ assert.equal(extractMeetingUrl("not an array"), null);
assert.equal(extractMeetingUrl([null, undefined, ""]), null);
assert.equal(extractMeetingUrl(["Conference Room 4B", "https://example.com/agenda"]), null);
});
+
+test("getMeetingJoinUrl trims hangout_link and skips whitespace-only links", async () => {
+ const { getMeetingJoinUrl } = await load();
+
+ const eventWithSpace = {
+ hangout_link: " https://meet.google.com/abc-defg-hij ",
+ };
+ assert.equal(getMeetingJoinUrl(eventWithSpace), "https://meet.google.com/abc-defg-hij");
+
+ const eventWithWhitespaceOnly = {
+ hangout_link: " ",
+ conference_data: JSON.stringify({
+ entryPoints: [{ entryPointType: "video", uri: " https://zoom.us/j/123 " }],
+ }),
+ };
+ assert.equal(getMeetingJoinUrl(eventWithWhitespaceOnly), "https://zoom.us/j/123");
+});