Skip to content

Commit 772cb4f

Browse files
committed
Strip HTML from event link
The Google Calendar UI will often add HTML to the event link. The javascript expects just a plain text URL with no markup. This patch makes it work in both cases.
1 parent e9b0792 commit 772cb4f

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

static/js/events-calendar.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,16 @@ $.ajax({
3838
var link = null;
3939
if (ev.description) {
4040
var line1 = ev.description.split("\n")[0];
41-
if (line1.slice(0,7) === "http://" ||
42-
line1.slice(0,8) === "https://"
43-
) {
44-
link = line1.trim();
41+
// Strip HTML tags to extract bare URL
42+
// Google Calendar often wraps URLs in <a href="...">...</a>
43+
var hrefMatch = line1.match(/href=["']([^"']+)["']/);
44+
if (hrefMatch) {
45+
link = hrefMatch[1].trim();
46+
} else {
47+
var stripped = line1.replace(/<[^>]*>/g, '').trim();
48+
if (stripped.match(/^https?:\/\//)) {
49+
link = stripped;
50+
}
4551
}
4652
}
4753

0 commit comments

Comments
 (0)