Skip to content

Normalize social inputs and canonicalize profile URL generation#962

Open
xtyledan wants to merge 1 commit intorahuldkjain:mainfrom
xtyledan:main
Open

Normalize social inputs and canonicalize profile URL generation#962
xtyledan wants to merge 1 commit intorahuldkjain:mainfrom
xtyledan:main

Conversation

@xtyledan
Copy link
Copy Markdown

@xtyledan xtyledan commented Mar 5, 2026

Normalize social inputs before URL generation

Add canonical URL builder for social links

Correct Medium, YouTube, and HackerEarth profile URL formats

Use normalized handles for GitHub/Twitter badge and stats parameters

Add regression tests covering username, @handle, and pasted profile URL inputs

Verification:

npx vitest run src/lib/markdown-generator.test.ts → 3/3 tests passed

npm run type-check passed

Fixes malformed links when users provide usernames or full profile URLs in social fields.

🔄 Pull Request

📋 Type of Change (check all applicable)

  • 🐛 Bug Fix - Fixes an issue without breaking existing functionality
  • Feature - Adds new functionality
  • Performance - Improves performance without changing functionality
  • ♻️ Refactor - Code changes that neither fix bugs nor add features
  • 📚 Documentation - Updates to documentation, comments, or README
  • 🎨 Style - Code style changes (formatting, missing semi-colons, etc.)
  • 🧪 Test - Adding or updating tests
  • 🏗️ Build - Changes to build system or dependencies
  • 👷 CI/CD - Changes to CI/CD workflows
  • 🔒 Security - Security improvements or vulnerability fixes
  • Accessibility - Improves accessibility compliance
  • 📱 Mobile - Mobile-specific improvements
  • 🌐 i18n - Internationalization changes

📖 Description

Normalizes social profile inputs before generating links in the README output. Ensures usernames, @Handles, and full profile URLs produce valid canonical profile links for supported platforms. Fixes malformed URLs previously generated when inputs were not in the expected format and adds regression tests to guarantee correct behavior across the supported input patterns.

What changed?

  • Normalized social inputs before URL generation in src/lib/markdown-generator.ts.
  • Added canonical URL builder for social profile links.
  • Updated Medium, YouTube, and HackerEarth URL formats to generate correct profile URLs.
  • Switched GitHub and Twitter badge/stat parameters to use normalized handles.
  • Added regression tests covering multiple input formats in src/lib/markdown-generator.test.ts.

Why was this change made?

Users frequently enter social handles in inconsistent formats such as plain usernames, @handles, or full profile URLs. The generator previously assumed a single format, which caused malformed profile links to be generated.

How does this change help users?

All social inputs are normalized before URL generation. This ensures valid canonical URLs are produced regardless of whether users enter usernames, @handles, or pasted profile URLs.

🔗 Related Issues

  • Closes #
  • Fixes #
  • Related to #

🧪 Testing & Quality Assurance

Testing Done (check all applicable)

  • Manual testing - Tested functionality manually
  • 🧪 Unit tests - Added/updated unit tests
  • 🔄 Integration tests - Tested with other components
  • 📱 Mobile testing - Tested on mobile devices
  • Accessibility testing - Tested with screen readers/keyboard nav
  • 🌐 Cross-browser testing - Tested in multiple browsers
  • 🎨 Visual testing - Checked UI/UX in light/dark themes

Test Instructions

  1. Enter social usernames using three formats: username, @handle, and full profile URL.
  2. Generate the README.
  3. Verify that all generated social links resolve to valid profile URLs.

Expected Behavior

Generated README links should always resolve to valid social profile URLs regardless of the input format used.

📸 Screenshots/Recordings

Before

Inputs such as @username or full URLs could generate malformed profile links.

After

All supported input formats are normalized and produce valid canonical profile URLs.

📋 Checklist

Code Quality

  • 🔍 TypeScript - No TypeScript errors (npm run type-check)
  • 🧹 Linting - No ESLint errors (npm run lint)
  • 🎨 Formatting - Code is properly formatted (npm run format)
  • 🏗️ Build - Production build succeeds (npm run build)
  • Performance - No performance regressions introduced

Accessibility

  • WCAG Compliance - Follows WCAG 2.1 AA guidelines
  • ⌨️ Keyboard Navigation - All interactive elements are keyboard accessible
  • 🔍 Screen Reader - Proper ARIA labels and semantic HTML
  • 🎨 Color Contrast - Meets contrast requirements
  • 🎯 Focus Management - Visible focus indicators

Mobile & Responsive

  • 📱 Mobile Responsive - Works on mobile devices (320px+)
  • 🖥️ Desktop - Works on desktop (1024px+)
  • 📐 Tablet - Works on tablet sizes (768px+)
  • 🔄 Orientation - Works in portrait and landscape

Browser Compatibility

  • 🌐 Chrome - Latest version
  • 🦊 Firefox - Latest version
  • 🧭 Safari - Latest version
  • 📱 Mobile Safari - iOS Safari
  • 📱 Chrome Mobile - Android Chrome

Documentation

  • 📚 Code Comments - Added helpful comments for complex logic
  • 📖 Documentation - Updated relevant documentation
  • 📝 README - Updated README if needed
  • 🔄 Changelog - Will be auto-generated from conventional commits

Security & Privacy

  • 🔒 No Secrets - No API keys, passwords, or sensitive data exposed
  • 🛡️ Input Validation - Proper validation for user inputs
  • 🔐 XSS Prevention - Protected against XSS attacks
  • 🍪 Privacy Compliant - Follows GDPR/privacy requirements

🚀 Deployment Notes

  • No breaking changes - Backward compatible
  • Database changes - N/A (static site)
  • Environment variables - No new env vars needed
  • Third-party dependencies - No new external dependencies

📝 Additional Notes

Verification:

  • npx vitest run src/lib/markdown-generator.test.ts3/3 tests passed
  • npm run type-checkpassed

Regression tests confirm usernames, @handles, and pasted profile URLs generate correct canonical profile links.

👀 Reviewers


By submitting this PR, I confirm that:

Normalize social inputs before URL generation

Add canonical URL builder for social links

Correct Medium, YouTube, and HackerEarth profile URL formats

Use normalized handles for GitHub/Twitter badge and stats parameters

Add regression tests covering username, @handle, and pasted profile URL inputs

Verification:

npx vitest run src/lib/markdown-generator.test.ts → 3/3 tests passed

npm run type-check passed

Fixes malformed links when users provide usernames or full profile URLs in social fields.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant