Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve @ mention parsing for GitHub usernames #33

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

drichar
Copy link
Contributor

@drichar drichar commented Oct 10, 2024

This PR improves the @ mention parsing in the convertMentionsToLinks function to more accurately identify valid GitHub usernames while avoiding false positives. This addresses the issue raised in #32.

Usernames for user accounts on GitHub can only contain alphanumeric characters and dashes (-).

Key Changes

  • Updated regex to match GitHub's username requirements
  • Prevented matching of package names and email addresses
  • Excluded matches within code snippets, URLs, and Markdown links

You can test the new regex pattern here: https://regex101.com/r/vBdvdh/1

This update ensures that only valid GitHub usernames are converted to profile links.

Current Behavior

The following screenshot shows how package names are incorrectly being converted to GitHub profile links in v1.15.1

image

After This Change

With this PR, package names will no longer be converted to links, resolving the issue shown above.

- Update regex to correctly identify valid GitHub usernames
- Prevent false positives for package names and email addresses
- Exclude matches within code snippets, URLs, and Markdown links
@SethCohen SethCohen merged commit 925765f into SethCohen:master Oct 18, 2024
1 check passed
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.

2 participants