Fix: Sanitize event objects before indexing and iterate to 0.3.24
All checks were successful
Build SilverBullet Plug / build (push) Successful in 32s

This commit is contained in:
2026-02-18 10:12:10 -08:00
parent 53a3c0e5db
commit 3c69a3567b
6 changed files with 16 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
---
name: Library/sstent/icalendar
version: "0.3.23"
version: "0.3.24"
tags: meta/library
files:
- icalendar.plug.js

View File

@@ -1,6 +1,6 @@
{
"name": "icalendar-plug",
"version": "0.3.23",
"version": "0.3.24",
"nodeModulesDir": "auto",
"tasks": {
"sync-version": "deno run -A scripts/sync-version.ts",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
name: icalendar
version: 0.3.23
version: 0.3.24
author: sstent
index: icalendar.ts
# Legacy SilverBullet permission name

View File

@@ -1,7 +1,7 @@
import { clientStore, config, datastore, editor, index } from "@silverbulletmd/silverbullet/syscalls";
import { convertIcsCalendar } from "https://esm.sh/ts-ics@2.4.0";
const VERSION = "0.3.23";
const VERSION = "0.3.24";
const CACHE_KEY = "icalendar:lastSync";
console.log(`[iCalendar] Plug script executing at top level (Version ${VERSION})`);
@@ -103,13 +103,20 @@ async function fetchAndParseCalendar(source: any, hourShift = 0): Promise<any[]>
const pad = (n: number) => String(n).padStart(2, "0");
const localIso = finalDate.getFullYear() + "-" + pad(finalDate.getMonth() + 1) + "-" + pad(finalDate.getDate()) + "T" + pad(finalDate.getHours()) + ":" + pad(finalDate.getMinutes()) + ":" + pad(finalDate.getSeconds());
// Picking only essential fields and ensuring they are strings to avoid indexing issues
events.push({
...icsEvent,
name: icsEvent.summary || "Untitled Event",
start: localIso,
location: typeof icsEvent.location === "string" ? icsEvent.location : (icsEvent.location?.value || ""),
description: typeof icsEvent.description === "string" ? icsEvent.description : (icsEvent.description?.value || ""),
url: icsEvent.url || "",
tag: "ical-event",
sourceName: source.name
});
}
if (events.length > 0) {
console.log(`[iCalendar] Sample event from ${source.name}:`, JSON.stringify(events[0]));
}
return events;
} catch (err) {
console.error(`[iCalendar] Error fetching/parsing ${source.name}:`, err);