tangled
alpha
login
or
join now
timtinkers.online
/
lemoncalendar
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
webcal support
timtinkers.online
1 year ago
f3141223
1f35c76d
+18
-4
2 changed files
expand all
collapse all
unified
split
islands
URLInput.tsx
utils
calendarUtils.ts
+13
-3
islands/URLInput.tsx
···
47
47
// Handle URL input changes
48
48
const handleUrlChange = (e: Event) => {
49
49
const target = e.target as HTMLInputElement;
50
50
-
onChange(target.value);
51
51
-
if (onError) onError(null);
50
50
+
const newValue = target.value;
51
51
+
52
52
+
onChange(newValue);
53
53
+
54
54
+
// Validate URL format
55
55
+
if (onError) {
56
56
+
if (newValue && !newValue.match(/^(https?:\/\/|webcal:\/\/)/i)) {
57
57
+
onError("URL must begin with https://, http://, or webcal://");
58
58
+
} else {
59
59
+
onError(null);
60
60
+
}
61
61
+
}
52
62
};
53
63
54
64
// Handle URL input focus
···
75
85
value={value}
76
86
onInput={handleUrlChange}
77
87
onFocus={handleUrlFocus}
78
78
-
placeholder="https://example.com"
88
88
+
placeholder="https://, http://, or webcal://"
79
89
className="url-input"
80
90
ref={urlInputRef}
81
91
/>
+5
-1
utils/calendarUtils.ts
···
33
33
if (!icalUrl) {
34
34
throw new Error("Must provide an iCalendar URL.");
35
35
}
36
36
-
const response = await fetch(icalUrl);
36
36
+
37
37
+
// Convert webcal:// to https:// for fetching
38
38
+
const fetchUrl = icalUrl.replace(/^webcal:\/\//i, "https://");
39
39
+
40
40
+
const response = await fetch(fetchUrl);
37
41
if (!response.ok) {
38
42
throw new Error(
39
43
`Failed to fetch calendar data: ${response.statusText}`,