Skip to content

fix: use shared sanitizeFont in generateMonthlySVG and generateAutoThemeMonthlySVG#907

Merged
JhaSourav07 merged 3 commits into
JhaSourav07:mainfrom
KaparthyReddy:fix/monthly-sanitize-font-consistency
May 28, 2026
Merged

fix: use shared sanitizeFont in generateMonthlySVG and generateAutoThemeMonthlySVG#907
JhaSourav07 merged 3 commits into
JhaSourav07:mainfrom
KaparthyReddy:fix/monthly-sanitize-font-consistency

Conversation

@KaparthyReddy
Copy link
Copy Markdown
Contributor

Fixes #905

Description

Both generateMonthlySVG and generateAutoThemeMonthlySVG in lib/svg/generator.ts defined their own local sanitizeFont function:

const sanitizeFont = (name: string) => name.replace(/[^a-zA-Z0-9\s-]/g, '').trim();

This shadowed the imported sanitizeFont from lib/svg/sanitizer.ts and stripped single quotes from font names. The real shared sanitizer explicitly allows single quotes (/[^a-zA-Z0-9\s\-']/g), meaning font names behaved differently in monthly view vs the default view — a silent inconsistency with no error thrown.

The fix removes both local definitions and replaces them with the already-imported shared sanitizeFont, making font sanitization consistent across all badge views.

Files changed: lib/svg/generator.ts only — 2 lines removed, 2 lines simplified.

Pillar

  • 🛠️ Other (Bug fix, refactoring, docs)

Visual Preview

N/A — font sanitization logic fix, no visual change for valid font names.

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally.
  • I have run npm run format and npm run lint locally and resolved all errors.
  • My commits follow the Conventional Commits format.
  • I have updated README.md if I added a new theme or URL parameter.
  • I have starred the repo.
  • I have made sure that I have only one commit to merge in this PR.
  • The SVG output matches the CommitPulse "premium quality" aesthetic standard.
  • (Recommended) I joined the CommitPulse Discord community.

…emeMonthlySVG

- Both functions defined a local sanitizeFont that stripped single quotes
- This shadowed the imported sanitizeFont from lib/svg/sanitizer.ts
- Replace both local definitions with the shared imported function
- Ensures consistent font sanitization across all badge views
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 28, 2026

@KaparthyReddy is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown

👋 Hey @KaparthyReddy, welcome to CommitPulse! 🎉

Thanks for opening your first pull request — this is a big deal and we appreciate the effort!

While you wait for a review, please double-check:

  • ✅ You've read the CONTRIBUTING.md checklist
  • npm run lint, npm run format, and npm run test all pass locally
  • ✅ Your PR has a visual preview if it touches any SVG output
  • 💬 You've joined our Discord for faster PR feedback

A maintainer will review your PR shortly. Hang tight! 🚀

@github-actions github-actions Bot added type:bug Something isn't working as expected needs-rebase This PR has merge conflicts and needs a rebase. labels May 28, 2026
@github-actions
Copy link
Copy Markdown

⚠️ Hey @KaparthyReddy, this PR has merge conflicts with the main branch.

Please pull the latest changes and resolve the conflicts so we can review it!

git fetch origin
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once resolved, the needs-rebase label will be removed automatically on the next check. 🙌

@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label May 28, 2026
@github-actions
Copy link
Copy Markdown

🚨 Hey @KaparthyReddy, the CI Pipeline is failing on this PR and it has been marked as status:blocked.

Please fix the issues before this can be reviewed. Here's how:

1. Run checks locally before pushing:

npm run format:check   # Check Prettier formatting
npm run lint           # Run ESLint
npm run typecheck      # TypeScript type check
npm run test           # Run unit tests (Vitest)
npm run build          # Verify production build passes

2. Auto-fix common issues:

npm run format         # Auto-fix formatting with Prettier
npm run lint -- --fix  # Auto-fix lint errors where possible

3. Check the full failure log here:
👉 View CI Run

Once you push a fix and the CI passes, the status:blocked label will be removed automatically. 💪

@github-actions github-actions Bot removed status:blocked This PR is blocked due to a failing CI check. needs-rebase This PR has merge conflicts and needs a rebase. labels May 28, 2026
@JhaSourav07 JhaSourav07 added GSSoC 2026 level:beginner Small changes Usually isolated fixes or simple UI/text updates. quality:exceptional Outstanding contribution with exceptional implementation quality, testing. gssoc:approved PR has been reviewed and accepted for valid contribution points labels May 28, 2026
@github-actions github-actions Bot added this to the GSSoC 2026 milestone May 28, 2026
@JhaSourav07 JhaSourav07 merged commit c5b2b75 into JhaSourav07:main May 28, 2026
7 of 8 checks passed
@github-actions
Copy link
Copy Markdown

🎉 Congratulations @KaparthyReddy! Your PR has been successfully merged. 🚀

Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.

⚠️ Important for GSSoC Contributors:
You are strictly advised to join our Discord Server as it is mandatory for all GSSoC participants. All important announcements, point claims, and community discussions happen there.

Keep building! 💻✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved PR has been reviewed and accepted for valid contribution points GSSoC 2026 level:beginner Small changes Usually isolated fixes or simple UI/text updates. quality:exceptional Outstanding contribution with exceptional implementation quality, testing. type:bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] generateMonthlySVG uses a local sanitizeFont that strips single quotes, inconsistent with the shared sanitizer

3 participants