Commit 81f16f2
authored
fix(svg): truncate long usernames in badge header to prevent overflow (JhaSourav07#788)
## Description
Fixes JhaSourav07#623
## Pillar
- [x] 📐 Pillar 2 — Geometric SVG Improvement
## What changed
The username title in the SVG badge was rendered at a fixed font size
and position with no truncation or scaling in both the default renderer
(`lib/svg/generator.ts:181`) and the auto-theme renderer
(`lib/svg/generator.ts:326`).
Added a small `truncateUsername` helper that caps display length at 20
characters and appends an ellipsis for longer names. Applied
consistently across both rendering paths so the behavior is uniform
regardless of theme.
Tested locally with a 39-character username — header now stays within
badge bounds on both paths.
## Visual Preview
Tested with:
```
curl "https://commitpulse.vercel.app/api/streak?user=averylongusernamethatbreaks" -o overflow_test.svg
```
Username is now truncated cleanly inside the badge header.
## Checklist before requesting a review:
- [x] I have read the `CONTRIBUTING.md` file.
- [x] I have tested these changes locally
(`localhost:3000/api/streak?user=YOUR_USERNAME`).
- [x] I have run `npm run format` and `npm run lint` locally and
resolved all errors.
- [x] My commits follow the Conventional Commits format.
- [x] I have updated `README.md` if I added a new theme or URL
parameter.
- [x] I have starred the repo.
- [x] I have made sure that I have only one commit to merge in this PR.
- [x] The SVG output matches the CommitPulse quality standard.1 file changed
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
| |||
191 | 195 | | |
192 | 196 | | |
193 | 197 | | |
194 | | - | |
| 198 | + | |
195 | 199 | | |
196 | 200 | | |
197 | 201 | | |
| |||
370 | 374 | | |
371 | 375 | | |
372 | 376 | | |
373 | | - | |
| 377 | + | |
374 | 378 | | |
375 | 379 | | |
376 | 380 | | |
| |||
0 commit comments