Skip to content

Commit 98dbd58

Browse files
Slashgearclaude
andcommitted
fix(seo): escape XML special characters in sitemap video entries
Event titles from Meetup can contain '&' which breaks XML parsing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 29e3757 commit 98dbd58

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

app/sitemap.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ function youtubeVideoId(embedUrl: string): string | null {
1111
return match?.[1] ?? null;
1212
}
1313

14+
function escapeXml(str: string): string {
15+
return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
16+
}
17+
1418
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
1519
const years = await fetchYearsWithMeetups();
1620
const pastEvents = await fetchPastEvents();
@@ -68,9 +72,11 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
6872
const videoId = youtubeVideoId(talk.videoLink);
6973
if (!videoId) continue;
7074
videos.push({
71-
title: talk.title,
75+
title: escapeXml(talk.title),
7276
thumbnail_loc: `https://img.youtube.com/vi/${videoId}/0.jpg`,
73-
description: `${talk.title} - ${talk.speakers?.map((s) => s.name).join(', ') ?? ''} @ ${event.title}`,
77+
description: escapeXml(
78+
`${talk.title} - ${talk.speakers?.map((s) => s.name).join(', ') ?? ''} @ ${event.title}`,
79+
),
7480
});
7581
}
7682
}

0 commit comments

Comments
 (0)