From 3773e1736323c72addbe11e8b5e3dd0e9eeef0c9 Mon Sep 17 00:00:00 2001 From: Suresh <115452537+sureshsuriya@users.noreply.github.com> Date: Tue, 21 Jul 2026 23:15:31 +0530 Subject: [PATCH] feat: add customizable label URL parameter for card title --- lib/svg/generator.test.ts | 73 ++++++++++++++++++++++ lib/svg/generator.ts | 34 +++++++--- lib/validations.streakParamsSchema.test.ts | 34 ++++++++++ lib/validations.ts | 7 ++- types/index.ts | 2 +- 5 files changed, 140 insertions(+), 10 deletions(-) diff --git a/lib/svg/generator.test.ts b/lib/svg/generator.test.ts index e5dbf1080..781bbe279 100644 --- a/lib/svg/generator.test.ts +++ b/lib/svg/generator.test.ts @@ -2695,6 +2695,79 @@ describe('XML Validation - All Generator Outputs', () => { }); }); + describe('label parameter custom title rendering', () => { + const baseParams = { + user: 'avi', + bg: hexColor('0d1117'), + text: hexColor('c9d1d9'), + accent: hexColor('58a6ff'), + speed: '8s', + scale: 'linear', + } as const; + + it('renders custom label instead of uppercase username when custom label is supplied', () => { + const svg = generateSVG( + mockStats, + { + ...baseParams, + label: 'Team Streak', + }, + mockCalendar + ); + + assertValidSVG(svg); + expect(svg).toContain('Team Streak'); + expect(svg).not.toContain('AVI'); + }); + + it('sanitizes custom label to prevent XSS / XML Injection', () => { + const svg = generateSVG( + mockStats, + { + ...baseParams, + label: '', + }, + mockCalendar + ); + + assertValidSVG(svg); + expect(svg).not.toContain('